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 abs(sx - tx) > 5: ans += 2 sx //= 2 tx //= 2 ans += abs(sx - tx) print(ans)