#include using namespace std; using ll = long long; constexpr ll INF = 2'000'000'000'000'000'000; constexpr int LIMIT = 60; ll pow_2(int e) { return 1LL << e; } ll solve(ll s_x, ll s_y, ll t_x, ll t_y) { if (max(s_y, t_y) >= LIMIT) { return abs(s_y - t_y); } ll ans = INF; for (int h = max(s_y, t_y); h <= LIMIT; h++) { ll dist_x = abs(s_x / pow_2(h) - t_x / pow_2(h)); ll dist_y = (h - s_y) + (h - t_y); ans = min(ans, dist_x + dist_y); } return ans; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while (T--) { ll s_x, s_y, t_x, t_y; cin >> s_x >> s_y >> t_x >> t_y; cout << solve(s_x, s_y, t_x, t_y) << '\n'; } }