#include long long int f(long long int a, long long int b) { while (a > 0 && b > 0) { b--; a >>= 1; } return a; } void solve() { long long int sx, sy, tx, ty; scanf("%lld %lld %lld %lld", &sx, &sy, &tx, &ty); long long int ans, b; if (sy < ty) { b = ty - sy; sy = ty; } else { b = sy - ty; ty = sy; } if (sx > tx) { sx ^= tx; tx ^= sx; sx ^= tx; } ans = f(tx, ty) - f(sx, sy) + b; long long int i; for (i = sy; i < 100; i++) if (ans > f(tx, ty + i) - f(sx, sy + i) + b + 2 * i) ans = f(tx, ty + i) - f(sx, sy + i) + b + 2 * i; printf("%lld\n", ans); return; } int main() { int t; scanf("%d", &t); for (; t > 0; t--) solve(); return 0; }