import sys from collections import deque, Counter input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) li = lambda: list(mi()) inf = 2 ** 63 - 1 mod = 998244353 def solve(): a, b, c, d = mi() if a > b: a, b = b, a c, d = d, c if a <= c and b <= d and c < d: print(c - a + d - b) elif a <= c and b <= d and c > d: print(1 + d + (c - a)) elif a > c and b > d: print(2 + c + d) elif a <= c and b > d and c < d: if a == 1: print(3 + c + d) else: print(2 + c + d) elif a <= c and b > d and c > d: print(c - a + 1 + d) elif a > c and b <= d and c < d: print(1 + c + d - b) elif a > c and b <= d and c > d: print(2 + c + d) else: raise Exception for _ in range(ii()): solve()