Three numbers A, B and C are the inputs. Write a program to find second largest among them.

-----Input-----

The first line contains an integer T, the total number of testcases. Then T lines follow, each line contains three integers A, B and C. 

-----Output-----
For each test case, display the second largest among A, B and C, in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ A,B,C ≤ 1000000

-----Example-----
Input
3 
120 11 400
10213 312 10
10 3 450

Output

120
312
10

Difficulty: EASY

Solutions:
for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x < y and x > z or (x > y and x < z):
		print(x)
	elif y < x and y > z or (y > x and y < z):
		print(y)
	else:
		print(z)


t = int(input())
for i in range(0, t):
	(a, b, c) = map(int, input().split())
	lists = [a, b, c]
	lists = sorted(lists)
	print(lists[-2])


for _ in range(int(input())):
	l2 = list(map(int, input().split()))
	l2.sort()
	print(l2[-2])


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	a.sort()
	print(a[1])


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


for t in range(int(input())):
	(x, y, z) = map(int, input().split())
	m = max(x, y, z)
	if x == m:
		print(max(y, z))
	elif y == m:
		print(max(x, z))
	elif z == m:
		print(max(y, x))


x = int(input())
for i in range(x):
	s = list(map(int, input().split()))
	s.sort()
	print(s[1])


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


n = int(input())
for _ in range(n):
	input_list = input().split(' ')
	input_list = [int(x) for x in input_list]
	input_list.sort()
	print(input_list[1])


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	x = max(a, b, c)
	y = min(a, b, c)
	if a < x and a > y:
		print(a)
	elif b < x and b > y:
		print(b)
	else:
		print(c)


n = int(input())
for i in range(n):
	(x, y, z) = map(int, input().split())
	if x > y and x < z or (x > z and x < y):
		print(x)
	if y > x and y < z or (y < x and y > z):
		print(y)
	if z > y and z < x or (z < y and z > x):
		print(z)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	print(l[1])


for i in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	print(l[1])


n = int(input())
for i in range(n):
	lis = list(map(int, input().split()))
	lis.sort()
	print(lis[1])


T = int(input())
for i in range(0, T):
	l = [int(i) for i in input().split()]
	l.remove(max(l))
	print(max(l))


t = int(input())
i = 0
while i < t:
	i = i + 1
	(a, b, c) = list(map(int, input().split()))
	if a > b and a > c:
		if b > c:
			print(b)
		else:
			print(c)
	elif b > c and b > a:
		if a > c:
			print(a)
		else:
			print(c)
	elif a > b:
		print(a)
	else:
		print(b)


b = int(input())
for i in range(b):
	list = []
	(x, y, z) = map(int, input().split())
	list = [x, y, z]
	list.sort(reverse=True)
	print(list[1])


test = int(input())
for i in range(test):
	(a, b, c) = map(int, input().split())
	large_num = max(a, b, c)
	small_num = min(a, b, c)
	second_large = a + b + c - large_num - small_num
	print(second_large)


T = int(input())
for i in range(0, T):
	x = list(map(int, input().split()))
	x.sort()
	print(x[-2])


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


n = int(input())
for i in range(n):
	L1 = [int(i) for i in input().split()]
	max1 = max(L1)
	max2 = 0
	for i in L1:
		if int(i) != max1 and i > max2:
			max2 = i
	print(max2)


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


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	s = sorted(l)
	print(s[1])


x = int(input())
for l in range(x):
	y = list(map(int, input().split()))
	y.sort()
	print(y[len(y) - 2])


def get_input():
	s = []
	(a, b, c) = list(map(int, input().split()))
	s.append(a)
	s.append(b)
	s.append(c)
	s.sort()
	print(s[1])
n = int(input())
for i in range(n):
	get_input()


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	c = max(x, y, z)
	d = min(x, y, z)
	if c != x and d != x:
		print(x)
	elif c != y and d != y:
		print(y)
	else:
		print(z)


n = int(input())
for gtr in range(n):
	(a, b, c) = map(int, input().split())
	if a > b > c:
		print(b)
	elif c > b > a:
		print(b)
	elif b > c > a:
		print(c)
	elif c > a > b:
		print(a)
	elif a > c > b:
		print(c)
	elif b > a > c:
		print(a)


for _ in range(int(input())):
	n = list(map(int, input().split()))
	l = len(n)
	a = sorted(n)
	print(a[l - 2])


for i in range(int(input())):
	lst = list(map(int, input().split()))
	lst.pop(lst.index(max(lst)))
	print(max(lst))


try:
	t = int(input())
	for i in range(0, t):
		l = []
		(a, b, c) = map(int, input().split())
		l.append(a)
		l.append(b)
		l.append(c)
		w = max(l)
		l.remove(w)
		w = max(l)
		print(w)
except:
	pass


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	print(a[1])


n = int(input())
for i in range(n):
	arr = list(map(int, input().split()))
	arr.remove(max(arr))
	print(max(arr))


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	l = [a, b, c]
	m = sorted(l)
	print(m[1])


a = int(input(''))
A = []
for m in range(a):
	(x, y, z) = [int(q) for q in input('').split()]
	B = [x, y, z]
	A.append(B)
for m in range(a):
	A1 = max(A[m])
	A[m].remove(A1)
	A2 = max(A[m])
	print(A2)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(sorted([a, b, c])[1])


num = int(input())
for i in range(num):
	n1 = list(map(int, input().split(' ')))
	n1.pop(n1.index(max(n1)))
	print(max(n1))


t = int(input())
while t:
	t -= 1
	(a, b, c) = list(map(int, input().split()))
	if a > b and a < c or (a > c and a < b):
		print(a)
	elif b > a and b < c or (b > c and b < a):
		print(b)
	elif c > a and c < b or (c > b and c < a):
		print(c)
	elif a == b or a == c:
		print(a)
	elif b == c:
		print(b)


for t in range(int(input())):
	list1 = list(map(int, input().split()))
	list1.sort()
	print(list1[-2])


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	p = sorted(a)
	print(p[1])


for i in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	print(a[-2])


t = int(input())
for i in range(t):
	tlist = []
	(a, b, c) = map(int, input().split())
	tlist.append(a)
	tlist.append(b)
	tlist.append(c)
	tlist.sort()
	print(tlist[1])


t = int(input())
for _ in range(t):
	nums = list(map(int, input().split()))
	print(sorted(nums)[1])


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


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a == max(a, b, c) and b == min(a, b, c) or (a == min(a, b, c) and b == max(a, b, c)):
		print(c)
	if c == max(a, b, c) and b == min(a, b, c) or (c == min(a, b, c) and b == max(a, b, c)):
		print(a)
	if a == max(a, b, c) and c == min(a, b, c) or (a == min(a, b, c) and c == max(a, b, c)):
		print(b)


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	if a > b and b > c or (c > b and b > a):
		print(b)
	elif b > a and a > c or (c > a and a > b):
		print(a)
	elif b > c and c > a or (a > c and c > b):
		print(c)


t = int(input())
for i in range(t):
	p = (x, y, z) = list(map(int, input().split()))
	p.sort()
	print(p[1])


test = int(input())
for i in range(test):
	(a, b, c) = map(int, input().split())
	if a >= b and b >= c or (a <= b and b <= c):
		print(b)
	elif a >= c and c >= b or (a <= c and b >= c):
		print(c)
	else:
		print(a)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	large_num = max(a, b, c)
	small_num = min(a, b, c)
	second_largest = a + b + c - large_num - small_num
	print(second_largest)


n = int(input(''))
l = []
li = []
lis = []
for i in range(n):
	(a, b, c) = input('').split()
	l.append(a)
	li.append(b)
	lis.append(c)
for i in range(n):
	s = max(int(l[i]), int(li[i]), int(lis[i]))
	d = min(int(l[i]), int(li[i]), int(lis[i]))
	print(int(l[i]) + int(li[i]) + int(lis[i]) - (s + d))


T = int(input())
for z in range(T):
	H = input().split()
	A = int(H[0])
	B = int(H[1])
	C = int(H[2])
	if A > B:
		if A > C:
			if B > C:
				print(B)
			else:
				print(C)
		else:
			print(A)
	elif A > C:
		print(A)
	elif B > C:
		print(C)
	else:
		print(B)


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


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


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	print(l[1])
	t -= 1


x = int(input())
for i in range(x):
	lst = [int(item) for item in input().split()]
	lst.sort()
	print(lst[-2])


t = int(input())
for i in range(t):
	L = list(map(int, input().split()))
	L.remove(max(L))
	print(max(L))


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


t = int(input())
for _ in range(t):
	numbers = sorted(list(map(int, input().split(' '))))
	print(numbers[-2])


for _ in range(int(input())):
	l = []
	n = input().split()
	for i in n:
		l.append(int(i))
	l.sort()
	print(l[1])


t = int(input())
for i in range(0, t):
	x = []
	(a, b, c) = list(map(int, input().split()))
	x = [a, b, c]
	x = sorted(x)
	print(x[1])


T = int(input())
for i in range(T):
	(A, B, C) = map(int, input().split())
	l = [A, B, C]
	l.sort()
	print(l[1])


n = int(input())
while n > 0:
	a = list(map(int, input().strip().split()))
	a.sort()
	print(a[1])
	n = n - 1


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	x = max(l)
	while max(l) == x:
		l.remove(x)
	print(max(l))


t = int(input())
for i in range(0, t):
	large = list(map(int, input().split()))
	large.sort(reverse=True)
	print(large[1])


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