for _ in range(int(input())): sx, sy, tx, ty = map(int, input().split()) if sx > tx: sx, sy, tx, ty = tx, ty, sx, sy cost = abs(sy - ty) sy = ty = max(sy, ty) if sy > 60: sx = tx = 0 else: sx = sx >> sy tx = tx >> ty ans = cost + tx - sx while tx != sx: cost += 2 sx >>= 1 tx >>= 1 ans = min(ans, cost + tx - sx) print(ans)