#include using namespace std; using ll=long long; using pii=pair; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); int t; cin >> t; while(t--){ int a,b,c,d; cin >> a >> b >> c >> d; if(cb){ if(a<=c) cout << c-a+(b<=d?d-b:d+1) << "\n"; else cout << c+d+2+(b==1) << "\n"; } else{ if(a<=c) cout << c-a+d+1 << "\n"; else cout << c+d+2 << "\n"; } } }