import sys import os import inspect input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) if os.getenv("TKTKLOCAL", False): def debug(*arg, sep=" ", end="\n"): print(*arg, sep=sep, end=end, file=sys.stderr) def debug_indent(*arg, sep=" ", end="\n", indent=" "): frame = inspect.currentframe().f_back par_func = inspect.getframeinfo(frame).function if par_func == "": debug(*arg, sep=sep, end=end) return frame_stack = inspect.stack() if len(frame_stack) > 30: return depth = sum(f.function == par_func for f in frame_stack) debug(indent * (depth - 1), end="") debug(*arg, sep=sep, end=end) else: def debug(*arg, **kwarg): pass def debug_indent(*arg, **kwarg): pass def calc(): A, B, C, D = map(int, input().split()) if A < B: A, B = B, A C, D = D, C if C > D: if A <= C: if B <= D: return C - A + D - B return 1 + (C - A) + D else: shift_y = abs(max(2, B) - B) return shift_y + 3 + (C - 1) + (D - 0) else: if D >= B: shift_y = abs(max(1, B) - B) return shift_y + 1 + (C - 0) + (D - B) else: return 3 + (C - 1) + D def main(): T = int(input()) for _ in range(T): print(calc()) main()