#include #define rep(i, n) for (int i = 0; i<(int) (n);i++) using namespace std; using ll = long long; #define lrep(i, n) for(ll i = 0; i<(ll) (n);i++) ll INF = LLONG_MAX; using vi = vector; using vl = vector; using vb = vector; int main(){ ll t; cin >> t; rep(_, t){ ll sx, sy, tx, ty, nsx, ntx; cin >> sx >> sy >> tx >> ty; if(sx > tx){ swap(sx, tx); swap(sy, ty); } nsx = sx; ntx = tx; ll k = sy, cost = INF; rep(i, k){ if(nsx == 0 && ntx == 0) continue; nsx /= 2; ntx /= 2; } if(sy <= ty){ while(ntx - nsx > 0){ if(cost >= (k - sy) + abs(k - ty) + ntx - nsx){ cost = (k - sy) + abs(k - ty) + ntx - nsx; } k++; nsx /= 2; ntx /= 2; } cost = min(cost, (k - sy) + abs(k - ty) + ntx - nsx); }else{ while(ntx - nsx > 0){ if(cost >= 2*(k - sy) + ntx - nsx){ cost = 2*(k - sy) + ntx - nsx; } k++; nsx /= 2; ntx /= 2; } cost = min(cost, 2*(k - sy) + ntx - nsx); cost += abs(sy - ty); } cout << cost << endl; } return 0; }