#include #include #include #include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { ll Sx, Sy, Tx, Ty; cin >> Sx >> Sy >> Tx >> Ty; ll ans = 1ll << 60; for (ll y = 0; y < 60; y++) { ans = min(ans, abs(Sx - Tx) + abs(Sy - y) + abs(Ty - y)); Sx /= 2; Tx /= 2; } if (60 <= Sy || 60 <= Ty) ans = min(ans, abs(Sy - Ty)); cout << ans << '\n'; } }