#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); } long long ans = Ty - Sy; if (Ty >= 61) { ans += 0; } else { unsigned long long pw = 1ull << Ty; Sx /= pw; Tx /= pw; ans += max(Sx, Tx) - min(Sx, Tx); } cout << ans << endl; } int main() { int T = 1; cin >> T; while (T--) { solve(); } return 0; }