import sys import math # 入力高速化 #input = sys.stdin.readline # 再帰回数上限 sys.setrecursionlimit(10**9) # よくあるmod #MOD = 1000000007 MOD = 998244353 def is_inside(y, x, h, w): return (0 <= y < h and 0 <= x < w) def solve(): # 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7 sx, sy, tx, ty = map(int, input().split()) if sx > tx: sx, tx = tx, sx sy, ty = ty, sy k = sy cost = 10**20 cur = 2**k while abs(sx - tx) + 1 >= 2**(k-1): if cost >= (k - sy) + abs(k - ty) + (tx // (cur) - sx // (cur)): cost = (k - sy) + abs(k - ty) + (tx // (cur) - sx // (cur)) k += 1 cur *= 2 print(cost) if __name__ == '__main__': T = int(input()) for _ in range(T): solve()