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(): sx, sy, tx, ty = map(int, input().split(' ')) if sx > tx: sx, tx = tx, sx sy, ty = ty, sy nsx = sx nsy = sy ntx = tx nty = ty k = sy cost = 10**20 for _ in range(k): if nsx == 0: break nsx //= 2 for _ in range(k): if ntx == 0: break 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 += 1 nsx //= 2 ntx //= 2 cost = min((k - sy) + abs(k - ty) + ntx - nsx, cost) else: while (ntx - nsx) > 0: if cost >= 2*(k - sy) + ntx - nsx: cost = 2*(k - sy) + ntx - nsx k += 1 nsx //= 2 ntx //= 2 cost = min(cost, 2*(k - sy) + ntx - nsx) cost += abs(sy - ty) print(cost) if __name__ == '__main__': T = int(input()) for _ in range(T): solve()