#include using namespace std; using ll = long long; #define rep(i, n) for (ll i = 0; i < (n); i++) void solve() { ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; ll ans = abs((sx>>min(63LL, max(sy, ty))) - (tx>>min(63LL, max(sy, ty)))) + abs(sy - ty); for (ll y = max(sy, ty); y <= 64; y++) ans = min(ans, abs((sx>>min(63LL, y)) - (tx>>min(63LL, y))) + 2*y - sy - ty); cout << ans << endl; } int main() { ll t; cin >> t; while (t--) solve(); return 0; }