Chef is making a dish that consists of exactly two ingredients. He has four ingredients A, B, C and D with tastiness a, b, c, and d respectively. He can use either A or B as the first ingredient and either C or D as the second ingredient. 

The tastiness of a dish is the sum of tastiness of its ingredients. Find the maximum possible tastiness of the dish that the chef can prepare.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- The first and only line of each test case contains four space-separated integers a, b, c, and d — the tastiness of the four ingredients.
   
------ Output Format ------ 

For each test case, output on a new line the maximum possible tastiness of the dish that chef can prepare.

------ Constraints ------ 

$1 ≤ T ≤ 100$
$1 ≤ a, b, c, d ≤ 100$

----- Sample Input 1 ------ 
2
3 5 6 2
16 15 5 4

----- Sample Output 1 ------ 
11
21
----- explanation 1 ------ 
Test case $1$: Chef can prepare a dish with ingredients $B$ and $C$ with a tastiness of $5+6=11$.

Test case $2$: Chef can prepare a dish with ingredients $A$ and $C$ with a tastiness of $16+5=21$.

Source: codechef | Difficulty: EASY
Tags: Mathematics

Implementation


Solutions:
t = int(input())
for tc in range(t):
	(a, b, c, d) = map(int, input().split())
	print(max(a, b) + max(c, d))


t = int(input())
while t > 0:
	(a, b, c, d) = map(int, input().split())
	print(max(max(a + c, b + d), max(a + d, b + c)))
	t -= 1


t = int(input())
for i in range(t):
	(A, B, C, D) = map(int, input().split())
	M = max(A, B)
	N = max(C, D)
	print(M + N)


T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b)
	y = max(c, d)
	print(x + y)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	if a > b:
		if c > d:
			print(a + c)
		else:
			print(a + d)
	elif c > d:
		print(b + c)
	else:
		print(b + d)


T = int(input())
for t in range(T):
	(a, b, c, d) = map(int, input().split())
	o1 = max(a, b) + max(c, d)
	print(o1)


T = int(input())
for i in range(T):
	(a, b, c, d) = map(int, input().split())
	my_list = [a, b]
	my_list2 = [c, d]
	my_list.sort(reverse=True)
	my_list2.sort(reverse=True)
	print(my_list[0] + my_list2[0])


n = int(input())
while n > 0:
	(a, b, c, d) = list(map(int, input().split()))
	print(max(a, b) + max(c, d))
	n -= 1


t = int(input())
for i in range(t):
	(a, b, c, d) = list(map(int, input().split()))
	A = max(a, b)
	B = max(c, d)
	S = A + B
	print(S)


t = int(input())
for i in range(0, t):
	(a, b, c, d) = map(int, input().split())
	if a < b:
		m = b
	else:
		m = a
	if c < d:
		n = d
	else:
		n = c
	print(m + n)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	p = max(a, b)
	q = max(c, d)
	print(p + q)


t = int(input())
for i in range(t):
	(x, y, z, n) = map(int, input().split())
	x1 = max(x, y)
	x2 = max(z, n)
	print(x1 + x2)


t = int(input())
for i in range(t):
	(a, b, c, d) = list(map(int, input().split()))
	print(max(a, b) + max(c, d))


T = int(input())
for i in range(T):
	(A, B, C, D) = map(int, input().split())
	if A > B:
		if C > D:
			print(A + C)
		else:
			print(A + D)
	elif C > D:
		print(B + C)
	else:
		print(B + D)


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	if a > b:
		i1 = a
	else:
		i1 = b
	if c > d:
		i2 = c
	else:
		i2 = d
	print(i1 + i2)


t = int(input())
for i in range(t):
	(w, x, y, z) = map(int, input().split())
	a = max(w, x)
	b = max(y, z)
	print(a + b)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	e = max(a, b)
	f = max(c, d)
	print(e + f)


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	print(max(a, b) + max(c, d))


def TestNess(*arg):
	M = max(arg[0], arg[1])
	N = max(arg[2], arg[3])
	print(M + N)
for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	TestNess(a, b, c, d)


t = int(input(''))
for _ in range(t):
	(a, b, c, d) = map(int, input('').split(' ', 4))
	sm = max(a + c, b + c, a + d, b + d)
	print(sm)


t = int(input())
for i in range(t):
	(m, n, o, p) = map(int, input().split())
	a = max(m, n)
	b = max(o, p)
	print(a + b)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	m = max(a, b)
	n = max(c, d)
	print(m + n)


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	First = max(a, b)
	Second = max(c, d)
	print(First + Second)


T = int(input())
for _ in range(T):
	(a, b, c, d) = map(int, input().split())
	if a >= b and c >= d:
		print(a + c)
	elif a >= b and c <= d:
		print(a + d)
	elif a <= b and c >= d:
		print(b + c)
	else:
		print(b + d)


for i in range(int(input())):
	(A, B, C, D) = map(int, input().split())
	print(max(A, B) + max(C, D))


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	l1 = [a, b]
	l1.sort()
	l2 = [c, d]
	l2.sort()
	print(l1[1] + l2[1])


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	max1 = max(a, b)
	max2 = max(c, d)
	print(max1 + max2)


T = int(input())
for i in range(0, T):
	(a, b, c, d) = map(int, input().split())
	print(max(a + c, a + d, b + c, b + d))


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split())
	A = a + c
	B = a + d
	C = b + c
	D = b + d
	print(max(A, B, C, D))


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split(' '))
	maxa = max(a, b)
	maxb = max(c, d)
	print(maxa + maxb)


n = int(input())
for i in range(0, n):
	lst = []
	lst1 = []
	(a, b, c, d) = map(int, input().split())
	lst.append(a)
	lst.append(b)
	lst1.append(c)
	lst1.append(d)
	print(max(lst1) + max(lst))


T = int(input())
while T > 0:
	(a, b, c, d) = map(int, input().split())
	A = a + c
	B = a + d
	C = b + c
	D = b + d
	print(max(A, B, C, D))
	T = T - 1


for t in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	m1 = max(a, b)
	m2 = max(c, d)
	add = m1 + m2
	print(add)


t = int(input(''))
for a in range(t):
	(a, b, c, d) = map(int, input().split())
	x = max(a, b)
	y = max(c, d)
	print(max(a, b) + max(c, d))


T = int(input())
for I in range(T):
	(a, b, c, d) = map(int, input().split())
	print(max(a + c, a + d, b + c, b + d))


t = int(input())
for i in range(t):
	(a, b, c, d) = map(int, input().split(' '))
	x = a + c
	y = a + d
	z = b + c
	h = b + d
	print(max(x, y, z, h))


num = int(input())
for i in range(num):
	(x, y, z, t) = map(int, input().split())
	print(max(x, y) + max(z, t))


for _ in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	ingredient_one = max(a + c, a + d)
	ingredient_two = max(b + c, b + d)
	if ingredient_one > ingredient_two:
		print(ingredient_one)
	else:
		print(ingredient_two)