INF = 2 * 10**18 LIMIT = 60 def solve(s_x: int, s_y: int, t_x: int, t_y: int) -> int: if max(s_y, t_y) >= LIMIT: return abs(s_y - t_y) ans = INF for h in range(max(s_y, t_y), LIMIT + 1): dist_x = abs(s_x // 2**h - t_x // 2**h) dist_y = (h - s_y) + (h - t_y) ans = min(ans, dist_x + dist_y) return ans T = int(input()) for _ in range(T): s_x, s_y, t_x, t_y = [int(s) for s in input().split()] print(solve(s_x, s_y, t_x, t_y))