T = int(input()) for t in range(T): sx, sy, tx, ty = map(int, input().split()) ans = abs(sy - ty) i = min(60, max(sy, ty)) sx //= 2 ** i tx //= 2 ** i while 1: if abs(sx - tx) - abs(sx // 2 - tx // 2) > 2: ans += 2 sx //= 2 tx //= 2 else: break ans += abs(sx - tx) print(ans)