import sys ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### for _ in range(ni()): a,b,c,d = na() if c > d: c, d = d, c a,b = b, a if a <= c and b <= d and a < b: print(d-b+c-a) elif b > d: if a == 1: print(d + c + 3) else: print(d + c + 2) elif a > c: print(1 + c + d - b) elif b < a: print(1 + c + d - b)