/* -*- coding: utf-8 -*- * * 3680.cc: No.3680 繧サ繧ー繝。繝ウ繝磯・繧・- yukicoder */ #include #include using namespace std; /* constant */ /* typedef */ using ll = long long; /* global variables */ /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { ll sx, sy, tx, ty; scanf("%lld%lld%lld%lld", &sx, &sy, &tx, &ty); ll ut = (sy < 60 ? (sx >> sy) : 0), uy = sy; ll vt = (ty < 60 ? (tx >> ty) : 0), vy = ty; ll d = 0; if (uy > vy) d = uy - vy, vt >>= min(60LL, d), vy = uy; else if (uy < vy) d += vy - uy, ut >>= min(60LL, d), uy = vy; ll mind = d + abs(ut - vt); while (ut != vt) { d += 2; ut >>= 1, vt >>= 1; mind = min(mind, d + abs(ut - vt)); } printf("%lld\n", mind); } return 0; }