Chef is given two integers A and C such that A ≤ C. 

Chef wants to find whether there exists any integer B such that A, B, and C are in [arithmetic progression].

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two space-separated integers A and C, the given integers.

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

For each test case, output -1 if there exists no integer B such that A, B, and C are in arithmetic progression. Else, output the value of B.

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

$1 ≤ T ≤ 60$
$1 ≤ A ≤ C ≤ 10$

----- Sample Input 1 ------ 
4
3 5
6 6
2 7
1 9

----- Sample Output 1 ------ 
4
6
-1
5

----- explanation 1 ------ 
Test case $1$: Considering $B = 4$, the three integers are in arithmetic progression as $B-A = C-B = 1$.

Test case $2$: Considering $B = 6$, the three integers are in arithmetic progression as $B-A = C-B = 0$.

Test case $3$: There exists no integral value of $B$ such that $A, B, $ and $C$ are in arithmetic progression.

Test case $4$: Considering $B = 5$, the three integers are in arithmetic progression as $B-A = C-B = 4$.

Source: codechef | Difficulty: EASY
Tags: Mathematics


Solutions:
a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	k = x + y
	if k % 2 == 0:
		print(int(k / 2))
	else:
		print('-1')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 0:
		print((a + b) // 2)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, c) = [int(x) for x in input().split()]
	if (a + c) % 2 == 1:
		print(-1)
	else:
		print((a + c) // 2)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print((a + b) // 2) if (a + b) % 2 == 0 else print(-1)


for i in range(int(input())):
	(a, c) = map(int, input().split())
	b = int((a + c) / 2)
	if a == c:
		print(a)
	elif b - a == c - b:
		print(int(b))
	else:
		print(-1)


t = int(input())
while t:
	(a, c) = map(int, input().split())
	b = (a + c) // 2
	print(b if b - a == c - b else -1)
	t -= 1


T = int(input())
for i in range(T):
	(A, C) = map(int, input().split())
	B = A + C
	if B % 2 == 0:
		print(int(B / 2))
	else:
		print(-1)


T = int(input())
for i in range(T):
	(a, b) = list(map(int, input().split()))
	if a == b:
		print(a)
	elif (b - a) % 2 != 0:
		print('-1')
	else:
		print(int((a + b) / 2))


n = int(input())
for i in range(n):
	(a, c) = map(int, input().split())
	flag = False
	for i in range(a, c + 1):
		if i - a == c - i:
			flag = True
			print(i)
			break
	if not flag:
		print(-1)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	if (x + y) % 2 == 0:
		print((x + y) // 2)
	else:
		print(-1)


for i in range(int(input())):
	flag = 0
	(a, b) = map(int, input().split())
	for i in range(a, b + 1):
		if i - a == b - i:
			print(i)
			flag = 1
	if flag == 0:
		print(-1)


t = int(input())
for i in range(t):
	c = list(map(int, input().split()))
	sum = c[0] + c[1]
	if sum % 2 == 0:
		print(sum // 2)
	else:
		print(-1)


for i in range(int(input())):
	(A, C) = map(int, input().split())
	B = -1
	for j in range(A, C + 1):
		if j - A == C - j:
			B = j
			break
	print(B)


for i in range(0, int(input())):
	(a, c) = map(int, input().split())
	if (a + c) % 2 == 0:
		print((a + c) // 2)
	else:
		print('-1')


for _ in range(int(input())):
	(a, c) = map(int, input().split())
	b = (a + c) / 2
	x = int((a + c) / 2)
	if b == x:
		print(x)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, c) = map(int, input().split())
	flag = 0
	if a == c:
		num = a
	else:
		for b in range(a, c):
			if b - a == c - b:
				flag = 1
				num = b
				break
			else:
				num = -1
	if flag == 1:
		print(num)
	else:
		print(num)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	while a != b and b > -1:
		a = a + 1
		b = b - 1
	print(b)


t = int(input())
for i in range(t):
	(a, c) = map(int, input().split())
	if a % 2 == 0 and c % 2 != 0 or (a % 2 != 0 and c % 2 == 0):
		print('-1')
	else:
		print((a + c) // 2)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	for j in range(11):
		if j - a == b - j:
			print(j)
			break
		elif j == 10:
			print('-1')


t = int(input())
for _ in range(t):
	(a, c) = map(int, input().split())
	ans = 0
	for i in range(1, 100):
		first = i - a
		second = c - i
		if first == second:
			ans = i
			break
		else:
			ans = -1
	print(ans)


t = int(input())
for i in range(t):
	(A, C) = list(map(int, input().split()))
	if (A + C) % 2 == 0:
		print((A + C) // 2)
	else:
		print(-1)


for t in range(int(input())):
	(a, c) = map(int, input().split())
	b = (a + c) // 2
	if b - a == c - b:
		print(b)
	else:
		print('-1')


t = int(input())
for tc in range(t):
	(a, c) = map(int, input().split())
	if (a + c) % 2 != 0:
		print('-1')
	else:
		print(int((a + c) / 2))


t = int(input())
for i in range(t):
	(a, c) = map(int, input().split())
	k = (c - a) // 2
	if a + k == c - k:
		print(a + k)
	else:
		print(-1)


for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	if (y - x) % 2 == 0 or (x - y) % 2 == 0:
		print(int((x + y) / 2))
	else:
		print(-1)


T = int(input())
for _ in range(T):
	(a, c) = map(int, input().split())
	if (a + c) % 2 == 0:
		print((a + c) // 2)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, c) = map(int, input().split())
	d = (a + c) // 2
	e = a + c
	if e % 2 == 0:
		print(d)
	else:
		print(-1)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split(' '))
	c = b - a
	if c % 2 == 0 and c != 0:
		d = int((a + b) / 2)
		print(d)
	elif c == 0:
		print(a)
	else:
		print(-1)


test = int(input())
while test > 0:
	(a, b) = map(int, input().split())
	if (a + b) % 2 == 0:
		print((a + b) // 2)
	else:
		print(-1)
	test = test - 1


t = int(input())
for _ in range(t):
	(a, c) = map(int, input().split())
	ans = None
	for i in range(a, c + 1):
		if i - a == c - i:
			ans = i
	if ans != None:
		print(ans)
	else:
		print(-1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	temp = 0
	for i in range(11):
		if i - x == y - i:
			print(i)
			temp += 1
	if temp == 0:
		print(-1)


import math
t = int(input())
for i in range(t):
	(a, c) = map(int, input().split())
	if abs(a - c) % 2 != 0:
		print(-1)
	else:
		print(math.ceil((a + c) / 2))


for _ in range(int(input())):
	(A, C) = map(int, input().split())
	if (C - A) % 2 == 0:
		B = A + (C - A) / 2
		print(int(B))
	else:
		print(-1)


n = int(input())
for _ in range(n):
	(a, c) = list(map(int, input().split()))
	if (a + c) % 2 == 0:
		print((a + c) // 2)
	else:
		print(-1)