Chef decided to redecorate his house, and now needs to decide between two different styles of interior design.

For the first style, tiling the floor will cost X_{1} rupees and painting the walls will cost Y_{1} rupees.

For the second style, tiling the floor will cost X_{2} rupees and painting the walls will cost Y_{2} rupees.

Chef will choose whichever style has the lower total cost. How much will Chef pay for his interior design?

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of a single line of input, containing 4 space-separated integers X_{1}, Y_{1}, X_{2}, Y_{2} as described in the statement.

------ Output Format ------ 

For each test case, output on a new line the amount Chef will pay for interior design.

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

$1 ≤ T ≤ 100$
$1 ≤ X_{1}, Y_{1}, X_{2}, Y_{2} ≤ 100$

----- Sample Input 1 ------ 
4
10 20 9 25
10 20 9 20
10 20 20 10
100 43 85 61

----- Sample Output 1 ------ 
30
29
30
143
----- explanation 1 ------ 
Test case $1$: The first style costs $10 + 20 = 30$ rupees, and the second costs $9 + 25 = 34$ rupees. The first is cheaper, so Chef will pay $30$ rupees.

Test case $2$: The first style costs $10 + 20 = 30$ rupees, and the second costs $9 + 20 = 29$ rupees. The second is cheaper, so Chef will pay $29$ rupees.

Test case $3$: The first style costs $10 + 20 = 30$ rupees, and the second costs $20 + 10 = 30$ rupees. Both styles cost the same, so Chef is always going to pay $30$ rupees.

Test case $4$: The first style costs $100 + 43 = 143$ rupees, and the second costs $85 + 61 = 146$ rupees. The first is cheaper, so Chef will pay $143$ rupees.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
for i in range(t):
	(x, y, z, a) = map(int, input().split(' '))
	x = x + y
	z = z + a
	if x > z:
		print(z)
	else:
		print(x)


for i in range(int(input())):
	(x, x1, y, y1) = list(map(int, input().split(' ')))
	x2 = x + x1
	y2 = y + y1
	print(y2) if x2 >= y2 else print(x2)


T = int(input())
for i in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 + y1 < x2 + y2:
		print(x1 + y1)
	else:
		print(x2 + y2)


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


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


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	print(min(x1 + y1, x2 + y2))


t = int(input())
for i in range(t):
	(xi, yi, xii, yii) = map(int, input().split())
	x = xi + yi
	y = xii + yii
	if x >= y:
		print(y)
	else:
		print(x)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	z1 = x1 + y1
	z2 = x2 + y2
	H = min(z1, z2)
	print(H)


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


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


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


t = int(input())
for _ in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	s = x1 + y1
	k = x2 + y2
	if s <= k:
		print(s)
	else:
		print(k)


t = int(input())
for i in range(t):
	(x, y, a, b) = map(int, input().split(' '))
	f = x + y
	s = a + b
	if f < s:
		print(f)
	else:
		print(s)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	z1 = x1 + y1
	z2 = x2 + y2
	if z1 < z2:
		print(z1)
	else:
		print(z2)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 + y1 <= x2 + y2:
		c = x1 + y1
		print(c)
	else:
		d = x2 + y2
		print(d)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	style1_cost = x1 + y1
	style2_cost = x2 + y2
	if style1_cost < style2_cost:
		print(style1_cost)
	else:
		print(style2_cost)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	first = x1 + y1
	second = x2 + y2
	if first <= second:
		print(first)
	else:
		print(second)


T = int(input())
for t in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	q = x1 + y1
	w = x2 + y2
	if q > w:
		print(w)
	elif q < w:
		print(q)
	elif q == w:
		print(q)
	else:
		print('nothing')


for i in range(int(input())):
	(X1, Y1, X2, Y2) = map(int, input().split())
	total_cost_F1 = X1 + Y1
	total_cost_F2 = X2 + Y2
	if total_cost_F1 < total_cost_F2:
		print(total_cost_F1)
	else:
		print(total_cost_F2)


a = int(input())
for i in range(a):
	(x, y, z, q) = map(int, input().split())
	a1 = x + y
	b1 = z + q
	print(min(a1, b1))


n = int(input())
for _ in range(n):
	(x1, y1, x2, y2) = map(int, input().split())
	design1 = x1 + y1
	design2 = x2 + y2
	print(min(design1, design2))


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


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


t = int(input())
for _ in range(t):
	(a, b, c, d) = map(int, input().split())
	e = a + b
	f = c + d
	if e < f:
		print(e)
	else:
		print(f)


T = int(input())
for _ in range(T):
	(x1, y1, x2, y2) = map(int, input().split())
	if x1 + y1 > x2 + y2:
		print(x2 + y2)
	elif x1 + y1 == x2 + y2:
		print(x1 + y1)
	else:
		print(x1 + y1)


n = int(input())
for i in range(0, n):
	(p, q, r, s) = map(int, input().split(' '))
	if p + q < r + s:
		print(p + q)
	else:
		print(r + s)


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = map(int, input().split())
	val = x1 + y1
	val1 = x2 + y2
	if val < val1:
		print(val)
	else:
		print(val1)


n = int(input())
for i in range(n):
	m = input().split()
	if int(m[0]) + int(m[1]) < int(m[2]) + int(m[3]):
		print(int(m[0]) + int(m[1]))
	else:
		print(int(m[2]) + int(m[3]))


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


n = int(input())
for i in range(n):
	(p, q, r, s) = map(int, input().split())
	print(min(p + q, r + s))


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


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	print(min(x1 + y1, x2 + y2))


t = int(input())
while t:
	(x1, y1, x2, y2) = map(int, input().split())
	s1 = x1 + y1
	s2 = x2 + y2
	print(s1 if s1 < s2 else s2)
	t -= 1


for i in range(int(input())):
	(a, b, c, d) = map(int, input().split())
	n1 = a + b
	n2 = c + d
	if n1 < n2:
		print(n1)
	else:
		print(n2)


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


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


T = int(input())
for i in range(0, T):
	(X1, Y1, X2, Y2) = input().split()
	x1 = int(X1)
	y1 = int(Y1)
	x2 = int(X2)
	y2 = int(Y2)
	style1 = x1 + y1
	style2 = x2 + y2
	if style1 < style2:
		print(style1)
	else:
		print(style2)


x = int(input())
while x != 0:
	(a, b, c, d) = map(int, input().split())
	if a + b < c + d:
		print(a + b)
	else:
		print(c + d)
	x -= 1


for _ in range(int(input())):
	(x1, y1, x2, y2) = map(int, input().split())
	x = x1 + y1
	y = x2 + y2
	if x < y:
		print(x)
	else:
		print(y)


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


t = int(input())
for i in range(t):
	(x1, y1, x2, y2) = list(map(int, input().split()))
	m = x1 + y1
	n = x2 + y2
	if m < n:
		print(m)
	else:
		print(n)


a = int(input())
for i in range(a):
	(l, m, x, y) = map(int, input().split())
	if l + m >= x + y:
		print(x + y)
	else:
		print(l + m)


T = int(input())
for i in range(T):
	(X1, Y1, X2, Y2) = map(int, input().split())
	print(min(X1 + Y1, X2 + Y2))


n = int(input())
for i in range(n):
	(j, k, l, m) = map(int, input().split())
	if j + k < l + m:
		print(j + k)
	else:
		print(l + m)


n = int(input())
for _ in range(n):
	(x, y, z, a) = map(int, input().split())
	print(min(x + y, z + a))


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


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


t = int(input())
for i in range(0, t):
	(x1, x2, y1, y2) = map(int, input().split())
	if x1 + x2 >= y1 + y2:
		print(y1 + y2)
	else:
		print(x1 + x2)