------ Problem Statement ------ 

Write a program that accepts sets of three numbers, and prints the second-maximum number among the three.

------ Input ------ 

First line contains the number of triples, N.
The next N lines which follow each have three space separated integers.

------ Output ------ 

For each of the N triples, output one new line which contains the second-maximum integer among the three.

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

$1 ≤ N ≤ 6$
$1 ≤ every integer ≤ 10000$
$The three integers in a single triplet are all distinct. That is, no two of them are equal.

----- Sample Input 1 ------ 
3
1 2 3
10 15 5
100 999 500
----- Sample Output 1 ------ 
2
10
500

Source: codechef | Difficulty: EASY


Solutions:
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 < c and b > a or (b > c and b < a):
		print(b)
	else:
		print(c)


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


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


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


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


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


tcase = int(input())
for i in range(tcase):
	(x, y, z) = map(int, input().split())
	ass = [x, y, z]
	print(sorted(ass)[1])


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


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


for _ in range(int(input())):
	nums = list(map(int, input().split()))
	nums.remove(max(nums))
	print(max(nums))


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


from statistics import median
t = int(input())
for _ in range(t):
	a = [int(x) for x in input().split()]
	print(median(a))


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


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


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


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


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


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


test = int(input())
ans = []
while test:
	test = test - 1
	(A, B, C) = [int(x) for x in input().split()]
	if A > B and A > C:
		if B > C:
			ans.append(B)
		else:
			ans.append(C)
	elif B > A and B > C:
		if A > C:
			ans.append(A)
		else:
			ans.append(C)
	elif C > A and C > B:
		if A > B:
			ans.append(A)
		else:
			ans.append(B)
for i in ans:
	print(i)


Test = int(input())
for i in range(Test):
	(a1, b1, c1) = map(int, input().split())
	A = [a1, b1, c1]
	print(sorted(A)[1])


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


t = int(input())
for i in range(t):
	l = [int(item) for item in input().split()]
	l.sort()
	print(l[1])


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


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


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


s = int(input())
for i in range(s):
	li = list(map(int, input().split()))
	d = max(li)
	li.remove(d)
	print(max(li))


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


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


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


a = int(input())
for i in range(a):
	x = list(map(int, input().split()))
	m = max(x)
	x.remove(m)
	n = min(x)
	x.remove(n)
	for j in x:
		print(j)


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


a = int(input())
for i in range(a):
	(x, y, z) = map(int, input().split())
	if x > y and x < z or (x < y and x > z):
		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 _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	v = [x, y, z]
	print(sorted(v)[1])


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


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


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


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


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


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


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


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


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	second_max = min(max(a, b), max(b, c), max(a, c))
	print(second_max)


t = int(input())
for i in range(t):
	(x, y, z) = [int(x) for x in input().split()]
	a = max(x, y, z)
	if a == x:
		print(max(y, z))
	elif a == y:
		print(max(x, z))
	elif a == z:
		print(max(x, y))


t = int(input())
for i in range(t):
	x = [int(x) for x in input().split()]
	x.sort()
	print(x[1])


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


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


t = int(input())
for i in range(t):
	(X, Y, Z) = map(int, input().split())
	if X > Y and X > Z and (Y > Z):
		print(Y)
	elif Y > Z and X > Z and (Y > X):
		print(X)
	elif Z > X and Z > Y and (Y > X):
		print(Y)
	elif Z > X and Z > Y and (X > Y):
		print(X)
	else:
		print(Z)


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


t = int(input())
for i in range(t):
	li = [int(x) for x in input().split()]
	li.remove(max(li))
	print(max(li))


t = int(input())
for _ in range(t):
	(x, y, z) = [int(x) for x in input().split()]
	if y > x > z or y < x < z:
		print(x)
	elif x > y > z or x < y < z:
		print(y)
	elif x > z > y or x < z < y:
		print(z)


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


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


t = int(input())
for i in range(t):
	(X, Y, Z) = map(int, input().split())
	m = max([X, Y, Z])
	mi = min([X, Y, Z])
	if not X == m and (not X == mi):
		print(X)
	elif not Y == m and (not Y == mi):
		print(Y)
	else:
		print(Z)


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


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