#include using namespace std; void solve() { long long sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; long long ans = 8e18; if (sy >= ty) { if (sy >= 60) { ans = min(ans, sy - ty); } else { ans = abs(sx / (1LL << sy) - tx / (1LL << sy)) + (sy - ty); } } if (sy >= 60) { ans = min(ans, abs(sy - ty)); } for (long long i = sy; i <= ty && i <= 60; i++) { ans = min(ans, abs(sx / (1LL << i) - tx / (1LL << i)) + abs(sy - ty)); } cout << ans << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { solve(); } return 0; }