Chef has three numbers A, B, and C.

He can do the following type of operation:
Select two numbers amongst A, B, and C;
Add 1 to the selected numbers;
Subtract 1 from the remaining number.

Determine whether Chef can make all the three numbers equal after applying the above operation any number of times.  
If yes, output the minimum number of operations required by Chef.

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

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

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

For each test case, output -1 if the numbers cannot be made equal, else output the minimum number of operations required to make them equal.

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

$1 ≤ T ≤ 10^{4}$
$1 ≤ A, B, C ≤ 10^{9}$

----- Sample Input 1 ------ 
4
1 1 2
3 7 3
4 4 4
1 2 3

----- Sample Output 1 ------ 
-1
2
0
-1

----- explanation 1 ------ 
Test case $1$: It can be proven that we cannot make the numbers equal using any number of operations.

Test case $2$: We require a minimum of $2$ operations to make the numbers equal:
- Operation $1$: Select the numbers $A$ and $C$. Thus, $A$ and $C$ become $3+1 = 4$ and $3+1 = 4$ respectively. Also, $B$ becomes $7-1 = 6$.
- Operation $2$: Select the numbers $A$ and $C$. Thus, $A$ and $C$ become $4+1 = 5$ and $4+1 = 5$ respectively. Also, $C$ becomes $6-1 = 5$.

Thus, all $3$ numbers are equal after $2$ operations.

Test case $3$: Since all $3$ numbers are already equal, we require no operations.

Test case $4$: It can be proven that we cannot make the numbers equal using any number of operations.

Source: codechef | Difficulty: MEDIUM_HARD


Solutions:
t = int(input())
for _ in range(t):
	l = list(map(int, input().split(' ')))
	l.sort()
	if not (l[1] - l[0]) % 2 and (not (l[2] - l[1]) % 2):
		sum = (l[1] - l[0]) // 2 + (l[2] - l[1]) // 2
		l[0] += sum
		l[1] += sum
		l[2] -= sum
		sum += (l[1] - l[0]) // 2
		print(sum)
	else:
		print(-1)


for _ in range(int(input())):
	l = sorted(list(map(int, input().split())))
	if l[0] % 2 == l[1] % 2 == l[2] % 2:
		print((l[2] - 2 * l[0] + l[1]) // 2)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif a % 2 == b % 2 == c % 2:
		tog = sorted([a, b, c])
		delt = (tog[2] - tog[0]) // 2 + (tog[1] - tog[0]) // 2
		print(delt)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = set([a, b, c])
	arr = sorted([a, b, c])
	if len(s) == 1:
		print(0)
	elif a % 2 == b % 2 and b % 2 == c % 2:
		print((arr[-1] - arr[0]) // 2 + (arr[1] - arr[0]) // 2)
	else:
		print(-1)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	if l[0] % 2 == l[1] % 2 and l[1] % 2 == l[2] % 2:
		l.sort()
		ans = (l[1] + l[2] - 2 * l[0]) // 2
		print(ans)
	else:
		print('-1')


def sol():
	l = list(map(int, input().split()))
	l.sort()
	if l.count(l[0]) == 3:
		return 0
	elif l[0] == l[1]:
		if (l[2] - l[0]) % 2 == 0:
			return int((l[2] - l[0]) / 2)
		else:
			return -1
	elif l[1] == l[2]:
		if (l[2] - l[0]) % 2 == 0:
			return l[2] - l[0]
		else:
			return -1
	elif l[0] % 2 == l[1] % 2 == l[2] % 2:
		z = l[2] - l[1]
		return int(z / 2 + l[1] - l[0])
	else:
		return -1
n = int(input())
for _ in range(n):
	print(sol())


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	d = 0
	l.sort()
	(a, b, c) = (l[0], l[1], l[2])
	if (b - a) % 2 == 0:
		d += (b - a) // 2
		a += d
		c += d
		b -= d
		if (c - b) % 2 == 0:
			print(d + (c - b) // 2)
		else:
			print(-1)
	elif (c - a) % 2 == 0:
		d += (c - a) // 2
		a += d
		c -= d
		b += d
		if (b - a) % 2 == 0:
			print(d + (b - a) // 2)
		else:
			print(-1)
	else:
		print(-1)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x == y and y == z:
		print(0)
		continue
	elif x % 2 == y % 2 == z % 2:
		a = sorted([x, y, z])
		ans = (a[1] - a[0]) // 2 + (a[2] - a[0]) // 2
		print(ans)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	arr = sorted([a, b, c])
	if a == b == c:
		print(0)
	elif a % 2 == b % 2 == c % 2:
		new = (arr[1] - arr[0]) // 2 + (arr[2] - arr[0]) // 2
		print(new)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print('0')
	elif a % 2 == b % 2 == c % 2:
		a1 = sorted([a, b, c])
		ans = (a1[2] - a1[0]) // 2 + (a1[1] - a1[0]) // 2
		print(ans)
	else:
		print('-1')


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	x = a[1] - a[0]
	y = a[2] - a[1]
	z = a[2] - a[0]
	if x % 2 == 0 and y % 2 == 0 and (z % 2 == 0):
		print((a[2] + a[1]) // 2 - a[0])
	else:
		print(-1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def solve():
	(hvjbhknlk, hjbkl, hgjklfcgvhbjnk) = map(int, input().split())
	dgfhjkcfgvhjk = abs(hvjbhknlk - hjbkl)
	cfhgvjbkl = abs(hvjbhknlk - hgjklfcgvhbjnk)
	wertyuio = abs(hjbkl - hgjklfcgvhbjnk)
	if dgfhjkcfgvhjk % 2 == 1 or cfhgvjbkl % 2 == 1 or wertyuio % 2 == 1:
		print('-1')
	else:
		xdcfgvhbjnkxcgvhbjnkdxfcgvhjkfcgvhbjnkl = 0
		while True:
			if hvjbhknlk == hjbkl and hjbkl == hgjklfcgvhbjnk:
				break
			if hvjbhknlk >= hjbkl and hvjbhknlk >= hgjklfcgvhbjnk:
				dgfhjkcfgvhjk = hvjbhknlk - hjbkl
				cfhgvjbkl = hvjbhknlk - hgjklfcgvhbjnk
				xcvbnmxcvghjfghj = min(dgfhjkcfgvhjk, cfhgvjbkl)
				if xcvbnmxcvghjfghj == 0:
					xcvbnmxcvghjfghj = max(dgfhjkcfgvhjk, cfhgvjbkl)
				xdcfgvhbjnkxcgvhbjnkdxfcgvhjkfcgvhbjnkl += xcvbnmxcvghjfghj // 2
				hvjbhknlk -= xcvbnmxcvghjfghj // 2
				hjbkl += xcvbnmxcvghjfghj // 2
				hgjklfcgvhbjnk += xcvbnmxcvghjfghj // 2
			elif hgjklfcgvhbjnk >= hvjbhknlk and hgjklfcgvhbjnk >= hjbkl:
				dgfhjkcfgvhjk = hgjklfcgvhbjnk - hjbkl
				cfhgvjbkl = hgjklfcgvhbjnk - hvjbhknlk
				xcvbnmxcvghjfghj = min(dgfhjkcfgvhjk, cfhgvjbkl)
				if xcvbnmxcvghjfghj == 0:
					xcvbnmxcvghjfghj = max(dgfhjkcfgvhjk, cfhgvjbkl)
				xdcfgvhbjnkxcgvhbjnkdxfcgvhjkfcgvhbjnkl += xcvbnmxcvghjfghj // 2
				hvjbhknlk += xcvbnmxcvghjfghj // 2
				hjbkl += xcvbnmxcvghjfghj // 2
				hgjklfcgvhbjnk -= xcvbnmxcvghjfghj // 2
			elif hjbkl >= hvjbhknlk and hjbkl >= hgjklfcgvhbjnk:
				dgfhjkcfgvhjk = hjbkl - hvjbhknlk
				cfhgvjbkl = hjbkl - hgjklfcgvhbjnk
				xcvbnmxcvghjfghj = min(dgfhjkcfgvhjk, cfhgvjbkl)
				if xcvbnmxcvghjfghj == 0:
					xcvbnmxcvghjfghj = max(dgfhjkcfgvhjk, cfhgvjbkl)
				xdcfgvhbjnkxcgvhbjnkdxfcgvhjkfcgvhbjnkl += xcvbnmxcvghjfghj // 2
				hvjbhknlk += xcvbnmxcvghjfghj // 2
				hjbkl -= xcvbnmxcvghjfghj // 2
				hgjklfcgvhbjnk += xcvbnmxcvghjfghj // 2
		print(xdcfgvhbjnkxcgvhbjnkdxfcgvhjkfcgvhbjnkl)
bvakjrbfkjafjkahrlehgkjarehkgjhakejhgkjaefhgjkabhlkjfgbkjabgkjalhfkafa = int(input())
for i in range(bvakjrbfkjafjkahrlehgkjarehkgjhakejhgkjaefhgjkabhlkjfgbkjabgkjalhfkafa):
	solve()


t = int(input())
for i in range(t):
	number = list(map(int, input().split()))
	number.sort()
	(a, b, c) = (number[0], number[1], number[2])
	if a % 2 == 0 and b % 2 == 0 and (c % 2 == 0) or (a % 2 == 1 and b % 2 == 1 and (c % 2 == 1)):
		mid = (a + b) // 2
		diff = mid - a
		c = c + diff
		mid = (mid + c) // 2
		diff = diff + (c - mid)
		print(diff)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if abs(a - b) % 2 == 0 and abs(b - c) % 2 == 0 and (abs(c - a) % 2 == 0):
		ar = [a, b, c]
		ar.sort()
		print((ar[1] + ar[2]) // 2 - ar[0])
	else:
		print(-1)
	t -= 1


testcase = int(input())
for _ in range(testcase):
	ABC = list(map(int, input().split()))
	ABC.sort()
	AB = abs(ABC[0] - ABC[1])
	BC = abs(ABC[0] - ABC[2])
	AC = abs(ABC[1] - ABC[2])
	if AB % 2 == 0 and BC % 2 == 0 and (AC % 2 == 0):
		stepX = (ABC[2] - ABC[0]) // 2
		stepY = (ABC[1] - ABC[0]) // 2
		print(stepX + stepY)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	x = abs(a - b)
	y = abs(a - c)
	z = abs(b - c)
	if x % 2 == 1 or y % 2 == 1 or z % 2 == 1:
		print(-1)
	else:
		ans = 0
		while 1:
			if a == b and b == c:
				break
			if a >= b and a >= c:
				x = a - b
				y = a - c
				diff = min(x, y)
				if diff == 0:
					diff = max(x, y)
				ans += diff // 2
				a -= diff // 2
				b += diff // 2
				c += diff // 2
			elif b >= a and b >= c:
				x = b - a
				y = b - c
				diff = min(x, y)
				if diff == 0:
					diff = max(x, y)
				ans += diff // 2
				a += diff // 2
				b -= diff // 2
				c += diff // 2
			elif c >= a and c >= b:
				x = c - b
				y = c - a
				diff = min(x, y)
				if diff == 0:
					diff = max(x, y)
				ans += diff // 2
				a += diff // 2
				b += diff // 2
				c -= diff // 2
		print(ans)


t = int(input())
while t > 0:
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	if abs(a - b) % 2 == 0 and abs(b - c) % 2 == 0 and (abs(c - a) % 2 == 0):
		arr = sorted([a, b, c])
		print(int((arr[2] + arr[1]) / 2) - arr[0])
	else:
		print(-1)
	t -= 1


for test_case in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a % 2 == b % 2 == c % 2:
		s = sorted([a, b, c])
		print((s[2] - s[0]) // 2 + (s[1] - s[0]) // 2)
	elif a == b == c:
		print('0')
	else:
		print('-1')


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif a % 2 == b % 2 == c % 2:
		ele = sorted([a, b, c])
		x = (ele[2] - ele[0]) // 2 + (ele[1] - ele[0]) // 2
		print(x)
	else:
		print(-1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	l = sorted([a, b, c])
	if l[0] == l[1] and (l[2] - l[1]) % 2 == 0 or (l[1] == l[2] and (l[1] - l[0]) % 2 == 0):
		if l[0] == l[1]:
			print((l[2] - l[1]) // 2)
		else:
			print(l[1] - l[0])
	elif (l[1] - l[0]) % 2 == 0 and (l[2] - l[1]) % 2 == 0:
		print((l[2] - l[1]) // 2 + (l[1] - l[0]))
	else:
		print('-1')


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print('0')
	elif a % 2 == b % 2 == c % 2:
		r = sorted([a, b, c])
		w = (r[2] - r[0]) // 2 + (r[1] - r[0]) // 2
		print(w)
	else:
		print('-1')


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif (a + b) % 2 == 0 and (a + c) % 2 == 0 and ((b + c) % 2 == 0) or ((a + b) % 2 != 0 and (a + c) % 2 != 0 and ((b + c) % 2 != 0)):
		arr = [a, b, c]
		arr.sort()
		avg = (arr[2] + arr[1]) // 2
		print(abs(avg - arr[0]))
	else:
		print(-1)


def soln():
	arr = [int(x) for x in input().split()]
	arr.sort()
	(n1, n2, n3) = arr
	if abs(n1 - n2) % 2 == 0 and abs(n1 - n3) % 2 == 0 and (abs(n2 - n3) % 2 == 0):
		return abs(n1 - n3) // 2 + abs(n1 - n2) // 2
	else:
		return -1
ntc = int(input())
for tc in range(ntc):
	print(soln())


test = int(input())
for i in range(test):
	a = list(map(int, input().split()))
	a = sorted(a)
	flag = True
	ans = 0
	for i in range(1, len(a)):
		if (a[i] - a[i - 1]) % 2 == 1:
			flag = False
		else:
			ans += (a[i] - a[0]) // 2
	if flag == False:
		print(-1)
	else:
		print(ans)


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


def ans(x):
	x.sort()
	if x[0] == x[1] == x[2]:
		return 0
	if x[0] % 2 == x[1] % 2 == x[2] % 2:
		(x, y) = (x[2] - x[0], x[1] - x[0])
		x = x // 2
		y = y // 2
		return x + y
	else:
		return -1
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	x = []
	x.extend([a, b, c])
	print(ans(x))


n = int(input())
for i in range(n):
	a = 3
	l = list(map(int, input().split()))[:a]
	l.sort()
	if (l[1] - l[0]) % 2 == 0 and (l[2] - l[1]) % 2 == 0:
		x = l[1] - l[0]
		l[0] += x / 2
		l[2] += x / 2
		y = l[2] - l[0]
		print(int(x / 2 + y / 2))
	else:
		print(-1)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	d1 = abs(a - b)
	d2 = abs(b - c)
	d3 = abs(a - c)
	if d1 % 2 or d2 % 2 or d3 % 2:
		print(-1)
	else:
		l = sorted([a, b, c])
		r1 = abs(l[0] - l[1]) // 2
		r2 = abs(l[0] - l[2]) // 2
		print(r1 + r2)
	t -= 1


for _ in range(int(input())):
	l = [int(x) for x in input().split()]
	l.sort()
	ans = 0
	if l.count(l[0]) == 3:
		print(0)
	elif (l[1] - l[0]) % 2 == 0 and (l[2] - l[0]) % 2 == 0:
		ans = (l[1] - l[0]) // 2
		s = (l[1] + l[0]) // 2
		l[2] += ans
		ans += (l[2] - s) // 2
		print(ans)
	else:
		print(-1)


import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def read_int():
	return int(input())

def read_int_list():
	return list(map(int, input().split()))

def read_string_list():
	return list(input())

def read_string_list_with_space():
	return list(input().split())

def read_string():
	return input()

def read_graph():
	(n, m) = read_int_list()
	graph = [[] for _ in range(n)]
	for _ in range(m):
		(u, v) = read_int_list()
		graph[u].append(v)
		graph[v].append(u)
	return graph

def execute():
	for _ in range(read_int()):
		arr = read_int_list()
		res = True
		arr.sort()
		count = -1
		if abs(arr[0] - arr[1]) % 2 == 1 or abs(arr[1] - arr[2]) % 2 == 1:
			res = False
		if res:
			count = 0
			d1 = (arr[1] - arr[0]) // 2
			count += d1
			arr[-1] += d1
			arr[1] -= d1
			d2 = (arr[-1] - arr[1]) // 2
			count += d2
		print(count)
execute()


T = int(input())
for i in range(T):
	(A, B, C) = input().split()
	A = int(A)
	B = int(B)
	C = int(C)
	a = min(A, B, C)
	c = max(A, B, C)
	v = [A, B, C]
	v.remove(a)
	v.remove(c)
	b = v[0]
	if (c - b) % 2 == 1 or (b - a) % 2 == 1:
		print(-1)
		continue
	ans = (c + b) / 2 - a
	print(int(ans))


t = int(input())
for i in range(0, t):
	(a, b, c) = map(int, input().split())
	l = [a, b, c]
	l.sort()
	d1 = l[1] - l[0]
	d2 = l[2] - l[0]
	if d1 % 2 == 0 and d2 % 2 == 0:
		print((d1 + d2) // 2)
	else:
		print(-1)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	if arr[1] - arr[0] == arr[2] - arr[1] == 0:
		print(0)
	elif (arr[1] - arr[0]) % 2 == 0 and (arr[2] - arr[1]) % 2 == 0:
		arr.sort()
		temp = arr[2] - arr[1]
		temp = temp // 2
		hold = arr[2] - temp
		pro = hold * 3 - sum(arr)
		print(pro)
	else:
		print(-1)


t = int(input())
while t > 0:
	a = list(map(int, input().split()))
	d = a[1] - a[0]
	e = a[2] - a[1]
	if d == e == 0:
		print('0')
	elif d % 2 == 0 and e % 2 == 0:
		a.sort()
		s = a[2] - a[1]
		s = int(s / 2)
		l = a[2] - s
		p = l * 3 - sum(a)
		print(p)
	else:
		print('-1')
	s = 0
	t = t - 1


case = int(input())
for _ in range(case):
	(m, n, o) = map(int, input().split(' '))
	a = min([m, n, o])
	c = max([m, n, o])
	if m >= n and m <= o or (m >= o and m <= n):
		b = m
	if n >= m and n <= o or (n >= o and n <= m):
		b = n
	if o >= m and o <= n or (o >= n and o <= m):
		b = o
	diff = c - a
	if diff & 1 == 1:
		print(-1)
		continue
	inc = b + diff // 2
	incina = a + diff // 2
	if abs(inc - incina) & 1 == 1:
		print(-1)
		continue
	print(diff // 2 + abs(inc - incina) // 2)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	arr = [a, b, c]
	arr.sort()
	g1 = arr[1] - arr[0]
	g2 = arr[2] - arr[1]
	if g1 % 2 == 0 and g2 % 2 == 0:
		print(g1 + g2 // 2)
	else:
		print(-1)


n = int(input())
for i in range(n):
	count = 0
	l = list(map(int, input().split()))
	while True:
		l.sort()
		if l[0] == l[1] == l[2]:
			print(count)
			break
		(a, b, c) = (l[0] % 2, l[1] % 2, l[2] % 2)
		if a == b == c:
			sub = (l[2] - l[0]) // 2
			l[0] += sub
			l[1] += sub
			l[2] -= sub
			count += sub
		else:
			print(-1)
			break


for t in range(int(input())):
	l = list(map(int, input().split()))
	l.sort()
	if (l[1] - l[0]) % 2 == 0:
		m = (l[1] - l[0]) / 2
		if (l[2] - l[1] + 2 * m) % 2 == 0:
			print(int(m + (l[2] - l[1] + 2 * m) / 2))
		else:
			print(-1)
	else:
		print(-1)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[0]
	b = arr[1]
	c = arr[2]
	if abs(a - b) % 2 == 0 and abs(b - c) % 2 == 0 and (abs(c - a) % 2 == 0):
		cout = (c - a) // 2
		cout += (b - a) // 2
		print(cout)
	else:
		print(-1)


def getMinForA(a, b, c):
	if b <= a and b <= c:
		return (b, a, c)
	elif c <= a and c <= b:
		return (c, b, a)
	else:
		return (a, b, c)

def getMinForB(b, c):
	if c < b:
		return (c, b)
	else:
		return (b, c)
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b and b == c and (a == c):
		print(0)
		continue
	if a - b & 1 or b - c & 1 or a - c & 1:
		print(-1)
	else:
		(a, b, c) = getMinForA(a, b, c)
		(b, c) = getMinForB(b, c)
		d1 = b - a
		d2 = c - a
		print(d1 // 2 + d2 // 2)


T = int(input())
for i in range(T):
	(a, b, c) = map(int, input().split())
	count = 0
	if a == b and b == c:
		print('0')
	elif a % 2 == b % 2 == c % 2:
		s = sorted([a, b, c])
		d = (s[2] - s[0]) // 2 + (s[1] - s[0]) // 2
		print(d)
	else:
		print('-1')


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	if a % 2 == b % 2 and b % 2 == c % 2:
		mini = min(a, b, c)
		updated = (a + b + c - mini) // 2
		print(3 * updated - a - b - c)
	else:
		print(-1)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if a == b and b == c and (a == c):
		print('0')
	elif a % 2 == b % 2 == c % 2:
		sortt = sorted([a, b, c])
		temp = (sortt[2] - sortt[0]) // 2 + (sortt[1] - sortt[0]) // 2
		print(temp)
	else:
		print('-1')


for i in range(int(input())):
	a = input().split()
	for i in range(0, len(a)):
		a[i] = int(a[i])
	a = sorted(a)
	d1 = a[2] - a[0]
	d2 = a[1] - a[0]
	if d1 % 2 == 0 and d2 % 2 == 0:
		print(int(d1 / 2) + int(d2 / 2))
	else:
		print('-1')


import math
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (abs(a - b), abs(a - c), abs(b - c))
	if a1 % 2 == 1 or b1 % 2 == 1 or c1 % 2 == 1:
		print(-1)
	else:
		q = 0
		while True:
			if a == b and b == c:
				break
			if a >= b and a >= c:
				a1 = a - b
				b1 = a - c
				d = min(a1, b1)
				if d == 0:
					d = max(a1, b1)
				q += math.floor(d / 2)
				a -= math.floor(d / 2)
				b += math.floor(d / 2)
				c += math.floor(d / 2)
			elif b >= a and b >= c:
				a1 = b - a
				b1 = b - c
				d = min(a1, b1)
				if d == 0:
					d = max(a1, b1)
				q += math.floor(d / 2)
				a += math.floor(d / 2)
				b -= math.floor(d / 2)
				c += math.floor(d / 2)
			elif c >= a and c >= b:
				a1 = c - b
				b1 = c - a
				d = min(a1, b1)
				if d == 0:
					sub = max(a1, b1)
				q += math.floor(d / 2)
				a += math.floor(d / 2)
				b += math.floor(d / 2)
				c -= math.floor(d / 2)
		print(q)


import os, sys, io, math
from re import *
from math import *
from array import *
from heapq import *
from bisect import *
from functools import *
from itertools import *
from statistics import *
from collections import *
I = lambda : [*map(int, sys.stdin.readline().split())]
IP = lambda : map(int, input().split())
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())

def f():
	(a, b, c) = IP()
	if a == b == c:
		return 0
	elif a % 2 == b % 2 == c % 2:
		l = sorted([a, b, c])
		return (l[2] - l[0]) // 2 + (l[1] - l[0]) // 2
	else:
		return -1
for _ in range(IN()):
	print(f())


for testcases in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif a == b or a == c or b == c:
		if b == c:
			(a, b, c) = (b, c, a)
		elif a == c:
			(a, b, c) = (a, c, b)
		else:
			(a, b, c) = (a, b, c)
		res = abs(c - a)
		if res % 2 != 0:
			print(-1)
		elif c > a:
			print(res // 2)
		else:
			print(res)
	else:
		l = [a, b, c]
		l.sort()
		x = l[2] - l[1]
		y = l[1] - l[0]
		if x % 2 == 0 and y % 2 == 0:
			print(x // 2 + y)
		else:
			print(-1)


t = int(input())
for i in range(t):
	lis = list(map(int, input().split(' ')))
	if lis[0] == lis[1] and lis[1] == lis[2]:
		print(0)
		continue
	lis.sort()
	if (lis[1] - lis[0]) % 2 != 0 or (lis[2] - lis[1]) % 2 != 0:
		print(-1)
		continue
	r = (lis[1] - lis[0]) // 2
	r += (lis[2] - lis[0]) // 2
	print(r)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif a % 2 == b % 2 == c % 2:
		sort = sorted([a, b, c])
		ans = (sort[2] - sort[0]) // 2 + (sort[1] - sort[0]) // 2
		print(ans)
	else:
		print(-1)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	a.sort()
	if (a[0] + a[1]) % 2 == 0 and (a[1] + a[2]) % 2 == 0:
		sum1 = (a[1] - a[0]) // 2
		a[0] += sum1
		a[2] += sum1
		sum2 = (a[2] - a[0]) // 2
		print(sum1 + sum2)
	else:
		print(-1)


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


for q in range(int(input())):
	(a, b, c) = sorted(list(map(int, input().split(' '))))
	if a % 2 == b % 2 and b % 2 == c % 2:
		print(int((a + b + c - min(a, b, c)) / 2) * 3 - (a + b + c))
	else:
		print(-1)


for i in range(int(input())):
	ar = list(map(int, input().split()))
	even = 0
	odd = 0
	ar.sort()
	for j in range(3):
		if ar[j] % 2 == 1:
			odd += 1
		else:
			even += 1
	if even == 3 or odd == 3:
		print((ar[2] + ar[1] - ar[0] - ar[0]) // 2)
	else:
		print(-1)


def solve(a):
	f1 = a[1] - a[0]
	if f1 % 2 == 1:
		return -1
	f2 = a[2] - a[1]
	if f2 % 2 == 1:
		return -1
	f = (2 * f1 + f2) // 2
	return f
t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	a.sort()
	print(solve(a))


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	(p, r) = (min(a, b, c), max(a, b, c))
	q = a + b + c - p - r
	(d, e) = (q - p, r - q)
	if (d & 1) + (e & 1) > 0:
		print(-1)
		continue
	print(d + e // 2)


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	(x, z) = (min(a, b, c), max(a, b, c))
	y = a + b + c - x - z
	(d, e) = (y - x, z - y)
	if (d & 1) + (e & 1) > 0:
		print(-1)
		continue
	print(d + e // 2)


def solve():
	arr = [int(i) for i in input().split()]
	arr.sort()
	if arr[0] % 2 != arr[1] % 2 or arr[0] % 2 != arr[2] % 2:
		print(-1)
		return
	print(int((arr[1] - 2 * arr[0] + arr[2]) / 2))
testCase = int(input())
while testCase:
	solve()
	testCase -= 1


for i in range(int(input())):
	(A, B, C) = map(int, input().split(' '))
	Ad = A % 2
	Bd = B % 2
	Cd = C % 2
	if Ad == Bd == Cd:
		L = [A, B, C]
		L.sort()
		if L[0] == L[1]:
			S = (L[2] - L[1]) // 2
		elif L[1] == L[2]:
			S = L[1] - L[0]
		elif L[0] == L[1] == L[2]:
			S = 0
		else:
			S = (L[1] + L[2]) // 2 - L[0]
		print(S)
	else:
		print('-1')


t = int(input())
for _ in range(t):
	abc = input().split()
	abc = [int(i) for i in abc]
	abc.sort()
	m = abc[1] - abc[0]
	n = abc[2] - abc[1]
	if m % 2 == 0 and n % 2 == 0:
		print(int(m + n / 2))
	else:
		print('-1')


def LII():
	return [int(x) for x in input().split()]
for _ in range(int(input())):
	v = LII()
	if len(set((x % 2 for x in v))) > 1:
		print(-1)
	else:
		print((sum(v) - len(v) * min(v)) // 2)


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


def fun(a, b, c):
	if a & 1 != b & 1 or a & 1 != c & 1:
		return -1
	arr = [a, b, c]
	arr.sort()
	return (arr[1] + arr[2] - 2 * arr[0]) // 2
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(fun(a, b, c))


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


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if a == b == c:
		print(0)
	elif a % 2 == b % 2 == c % 2:
		s = sorted([a, b, c])
		v1 = (s[2] - s[0]) // 2
		v2 = (s[1] - s[0]) // 2
		print(v1 + v2)
	else:
		print(-1)