#include using namespace std; using ll = long long; ll inf = (1LL<<60); int main() { int T; cin >> T; while(T){ T--; ll x,y,s,t; cin >> x >> y >> s >> t; ll ans = inf; for(ll i=0;i<=60;i++){ ll cst = abs(x - s); cst += abs(y - i) + abs(t - i); ans = min(ans,cst); x >>= 1LL; s >>= 1LL; } cout << ans << endl; } }