#if __has_include() #include #else #include #include #endif using namespace std; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) #define printYesNo(is_ok) puts(is_ok ? "Yes" : "No") #define SORT(v) sort(v.begin(), v.end()) #define RSORT(v) sort(v.rbegin(), v.rend()) #define REVERSE(v) reverse(v.begin(), v.end()) template void printVector(const Container &v, char delimiter = ' ') { for (auto itr = v.begin(); itr != v.end(); itr++) { if (itr != v.begin()) { cout << delimiter; } cout << *itr; } cout << endl; } template void printlnVector(const Container &v) { printVector(v, '\n'); } void solve() { unsigned long long Sx, Sy, Tx, Ty; cin >> Sx >> Sy >> Tx >> Ty; if (Sy > Ty) { swap(Sx, Tx); swap(Sy, Ty); } unsigned long long ans = ULONG_LONG_MAX; // cout << Sx << ", " << Sy << ", " << Tx << ", " << Ty << endl; // 高さtまで移動する for (unsigned long long t = Ty; t <= Ty + 60; t++) { unsigned long long d_y = t - Sy + t - Ty; unsigned long long d_x = 0; if (t >= 61) { d_x += 0; } else { unsigned long long pw = 1ull << t; unsigned long long s_i = Sx / pw; unsigned long long t_i = Tx / pw; d_x += max(s_i, t_i) - min(s_i, t_i); // cout << " " << s_i << ", " << t_i << endl; } // cout << t << ": " << d_y << " " << d_x << endl; ans = min(ans, d_x + d_y); } cout << ans << endl; } int main() { int T = 1; cin >> T; while (T--) { solve(); } return 0; }