#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int t; cin >> t; while (t--) { ll sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; if (sy < ty) { swap(sx, tx); swap(sy, ty); } ll ans = 0; if (sy > 60 && ty > 60) { ans += abs(ty - sy); sy = 60; ty = 60; } else if (sy > 60 && ty <= 60) { ans += abs(sy - 60); sy = 60; } ll d = 1LL << 61; for (ll i = sy; i <= 60; i++) { ll c = i - sy + i - ty; c += abs((sx >> i) - (tx >> i)); d = min(d, c); } cout << ans + d << endl; } return 0; }