Chef is playing a variant of Blackjack, where 3 numbers are drawn and each number lies between 1 and 10 (with both 1 and 10 inclusive). Chef wins the game when the sum of these 3 numbers is exactly 21.

Given the first two numbers A and B, that have been drawn by Chef, what should be 3-rd number that should be drawn by the Chef in order to win the game?

Note that it is possible that Chef cannot win the game, no matter what is the 3-rd number. In such cases, report -1 as the answer. 

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

- The first line will contain an integer T - number of test cases. Then the test cases follow.
- The first and only line of each test case contains two integers A and B - the first and second number drawn by the Chef.

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

For each testcase, output the 3-rd number that should be drawn by the Chef in order to win the game. Output -1 if it is not possible for the Chef to win the game. 

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

$1 ≤ T ≤ 100$
$1 ≤ A, B ≤ 10$

----- Sample Input 1 ------ 
3
1 10
1 5
4 9
----- Sample Output 1 ------ 
10
-1
8
----- explanation 1 ------ 
Test case $1$: The first two numbers are $1$ and $10$. If the third number will be $10$, the resulting sum will be $1 + 10 + 10 = 21$. So Chef will win the game if the third number is $10$.

Test case $2$: The first two numbers are $1$ and $5$. There is no number between $1$ and $10$, that can make the resulting sum $21$. Hence, the answer will be $-1$ in this test case.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split(' '))
	if a + b < 11:
		print(-1)
	else:
		print(21 - (a + b))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	if 21 - (a + b) <= 10:
		print(21 - (a + b))
	else:
		print(-1)


s = int(input())
while s:
	(o, p) = map(int, input().split())
	if 21 - (o + p) > 10:
		print(-1)
	else:
		print(21 - o - p)
	s -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	a = x + y
	if a <= 10:
		print('-1')
	else:
		print(21 - a)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	if a + b < 11:
		print(-1)
	else:
		print(21 - a - b)


n = int(input())
for i in range(n):
	sum1 = sum(list(map(int, input().split())))
	if 21 - sum1 > 10:
		print(-1)
	else:
		print(21 - sum1)


for i in range(int(input())):
	(f, g) = map(int, input().split())
	if f + g >= 11:
		print(21 - (f + g))
	else:
		print(-1)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	n = abs(a + b - 21)
	if a + b + n == 21 and n <= 10:
		print(n)
	else:
		print(-1)


for _ in range(int(input())):
	current = list(map(int, input().split()))
	if sum(current) >= 11:
		print(21 - sum(current))
	else:
		print(-1)


t = int(input())
for i in range(t):
	total = sum(list(map(int, input().split())))
	if 21 - total > 10:
		print(-1)
	else:
		print(21 - total)


testcase = int(input())
while testcase > 0:
	(a, b) = map(int, input().split())
	third_no = abs(21 - (b + a))
	if third_no >= 1 and third_no <= 10:
		print(third_no)
	else:
		print(-1)
	testcase -= 1


for i in range(int(input())):
	(s, d) = map(int, input().split())
	if s + d < 11:
		print(-1)
	else:
		print(21 - (s + d))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	r = 21 - x - y
	if 1 <= r <= 10:
		print(r)
	else:
		print(-1)


s = int(input())
for j in range(s):
	(x, y) = map(int, input().split())
	z = 21 - (x + y)
	if z <= 10:
		print(z)
	else:
		print('-1')


lis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	x = A + B
	for j in lis:
		if x + j == 21:
			print(j)
			break
	else:
		print('-1')


t = int(input())
for i in range(t):
	(A, B) = map(int, input().split())
	ABSum = A + B
	thirdCard = 21 - ABSum
	if thirdCard >= 1 and thirdCard <= 10:
		print(thirdCard)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	n = x + y
	if n >= 11:
		print(21 - n)
	else:
		print(-1)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if 21 - (x + y) >= 1 and 21 - (x + y) <= 10:
		print(21 - (x + y))
	else:
		print('-1')


f = int(input())
for x in range(f):
	sum1 = sum(list(map(int, input().split())))
	if 21 - sum1 > 10:
		print(-1)
	else:
		print(21 - sum1)


T = int(input())
for _ in range(T):
	(a, b) = map(int, input().split())
	c = 21 - a - b
	if c > 0 and c <= 10:
		print(c)
	else:
		print('-1')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	m = a + b
	n = 21 - m
	if n > 0 and n < 11:
		print(n)
	else:
		print(-1)


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	c = 21 - a - b
	if c >= 1 and c <= 10:
		print(c)
	else:
		print(-1)
	t -= 1


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	a = x + y
	if 21 - a > 0 and 21 - a < 11:
		print(21 - a)
	else:
		print(-1)


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	if a + b >= 11:
		print(21 - (a + b))
	else:
		print(-1)
	t -= 1


for i in range(int(input())):
	(x, y) = map(int, input().split())
	if abs(21 - (x + y) >= 11):
		print(-1)
	else:
		print(abs(21 - (x + y)))


n = int(input())
for i in range(0, n):
	(a, b) = map(int, input().split())
	if a + b >= 11:
		print(21 - (a + b))
	else:
		print(-1)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	blackjack = lambda a, b: 21 - a - b if 21 - a - b <= 10 else -1
	print(blackjack(a, b))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	needed = 21 - a - b
	if needed <= 10:
		print(needed)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	c = 21 - (a + b)
	if c <= 10 and c >= 1:
		print(c)
	else:
		print('-1')


T = int(input())
for i in range(T):
	(A, B) = map(int, input().split())
	if 21 - (A + B) <= 10:
		print(21 - (A + B))
	else:
		print(-1)


t = int(input())
for It in range(t):
	(m, n) = map(int, input().split())
	if m + n <= 10 or m + n >= 22:
		print(-1)
	else:
		print(21 - (m + n))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	v = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
	c = 21 - (a + b)
	if c in v:
		print(c)
	else:
		print('-1')


T = int(input())
for T in range(0, T):
	(A, B) = input().split()
	A = int(A)
	B = int(B)
	if A + B < 11:
		print(-1)
	else:
		print(21 - (A + B))


def black(x, y):
	p = 21 - (y + x)
	if p in range(0, 11):
		return p
	else:
		return -1
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	v = black(x, y)
	print(v)