import sys 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() ta = False tb = False if a > c: ta = True a = 0 if b > d: tb = True b = 0 #a <= c && b <= d if a > b: a, b = b, a c, d = d, c ta, tb = tb, ta if c > d: tb = True ans = 0 if ta: ans += 1 + c else: ans += c - a if tb: ans += 1 + d else: ans += d - b if ta and tb: if c == 1 or d == 1: ans += 1 print(ans) for _ in range(ii()): solve()