This question is similar to the $"Operation$ $on$ $a$ $Tuple"$ problem in this month's Long Challenge but with a slight variation.

Consider the following operations on a triple of integers. In one operation, you should:

- Choose a positive integer $d>0$ and an arithmetic operation - in this case, it will only be addition.

- Choose a subset of elements of the triple.

- Apply arithmetic operation to each of the chosen elements.

For example, if we have a triple $(3,5,7)$, we may choose to add $3$ to the first and third element, and we get $(6,5,10)$ using one operation.

You are given an initial triple $(p,q,r)$ and a target triple $(a,b,c)$. Find the maximum number of operations needed to transform $(p,q,r)$ into $(a,b,c)$ or say the conversion is impossible .
Input:
- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains three space-separated integers p, q and r.
- The second line contains three space-separated integers a, b and c.Output:
For each test case, print a single line containing one integer ― the maximum required number of operations(if the conversion is possible), or else print "-1"

Constraints:
- $1 \leq T \leq 1,000$
- $2 \leq |p|,|q|,|r|,|a|,|b|,|c| \leq 10^9$Sample Input:
	1

	2 2 1

	3 3 2

Sample Output:
	3

Source: codechef | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
T = int(input())
while T > 0:
	T -= 1
	(p, q, r) = list(map(int, input().split()))
	(a, b, c) = list(map(int, input().split()))
	s = 0
	d1 = a - p
	if d1 > 0:
		s += d1
	d2 = b - q
	if d2 > 0:
		s += d2
	d3 = c - r
	if d3 > 0:
		s += d3
	if d1 == 0 and d2 == 0 and (d3 == 0):
		print(0)
	elif d1 < 0 or d2 < 0 or d3 < 0:
		print(-1)
	else:
		print(s)


for _ in range(int(input())):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt = 0
	if b[0] - a[0] < 0 or b[1] - a[1] < 0 or b[2] - a[2] < 0:
		print(-1)
	elif a == b:
		print(0)
	else:
		for i in range(3):
			if b[i] - a[i] != 0:
				cnt += b[i] - a[i]
		print(cnt)


for i in range(int(input())):
	giv = [int(i) for i in input().split()]
	tar = [int(i) for i in input().split()]
	diff = set()
	f = 0
	c = 0
	s = 0
	for i in range(3):
		if tar[i] - giv[i] == 0:
			c += 1
		elif tar[i] - giv[i] < 0:
			f = 1
			break
		else:
			s += tar[i] - giv[i]
	if f == 1:
		print(-1)
	else:
		print(s)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	f = 0
	for i in range(len(l)):
		p = k[i] - l[i]
		if p < 0:
			f = -1
			break
		else:
			f += p
	print(f)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	a = ip()
	b = ip()
	d = [0] * 3
	for i in range(3):
		d[i] = b[i] - a[i]
	ans = 0
	flag = 0
	for i in d:
		if i < 0:
			flag = 1
			break
		elif i > 0:
			ans += i
	if flag:
		print(-1)
	else:
		print(ans)


import sys
R = lambda t=int: t(eval(input()))
RL = lambda t=int: [t(x) for x in input().split()]
RLL = lambda n, t=int: [RL(t) for _ in range(n)]

def solve():
	(p, q, r) = RL()
	(a, b, c) = RL()
	if p > a or q > b or r > c:
		print(-1)
		return
	print(a - p + b - q + c - r)
T = R()
for t in range(1, T + 1):
	solve()


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	(p, q, r) = map(int, input().split())
	print(-1) if p < a or q < b or r < c else print(p + q + r - (a + b + c))


for _ in range(int(input())):
	(p, q, r) = list(map(int, input().split()))
	(a, b, c) = list(map(int, input().split()))
	l = []
	l.append(a - p)
	l.append(b - q)
	l.append(c - r)
	ans = 3
	ans -= l.count(0)
	for i in l:
		if i < 0:
			print(-1)
			break
	else:
		print(sum(l))


try:
	t = int(input())
	for _ in range(t):
		(p, q, r) = list(map(int, input().split()))
		(a, b, c) = list(map(int, input().split()))
		if a < p or b < q or c < r:
			print(-1)
		else:
			print(a - p + b - q + c - r)
except EOFError:
	pass


t = int(input())
while t > 0:
	(p, q, r) = list(map(int, input().split()))
	(a, b, c) = list(map(int, input().split()))
	x = a - p
	y = b - q
	z = c - r
	if x < 0 or y < 0 or z < 0:
		print('-1')
	elif x == 0 and y == 0 and (z == 0):
		print('0')
	elif x == 0 and y == 0:
		print(z)
	elif y == 0 and z == 0:
		print(x)
	elif x == 0 and z == 0:
		print(y)
	elif x == 0:
		print(y + z)
	elif y == 0:
		print(x + z)
	elif z == 0:
		print(x + y)
	else:
		print(x + y + z)
	t -= 1


for ts in range(int(input())):
	l = list(map(int, input().split()))
	k = list(map(int, input().split()))
	f = 0
	for i in range(len(l)):
		p = k[i] - l[i]
		if p < 0:
			f = -1
			break
		elif p == 0:
			continue
		else:
			f += p
	print(f)


for _ in range(int(input())):
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	(c, f) = (0, 0)
	for i in range(3):
		if arr[i] > arr2[i]:
			f = 1
			break
		else:
			c = c + arr2[i] - arr[i]
	if f == 1:
		print(-1)
	else:
		print(c)


for u in range(int(input())):
	l = list(map(int, input().split()))
	d = list(map(int, input().split()))
	c = []
	f = 0
	for i in range(3):
		if d[i] < l[i]:
			f = 1
			break
	if f == 1:
		print(-1)
	else:
		s = 0
		for i in range(3):
			s = s + d[i] - l[i]
		print(s)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(p, q, r) = iia()
	(a, b, c) = iia()
	if a < p or b < q or c < r:
		print(-1)
	else:
		add = [a - p, b - q, c - r]
		print(sum(add))


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	d = m[0] - l[0]
	e = m[1] - l[1]
	f = m[2] - l[2]
	if d < 0 or e < 0 or f < 0:
		print(-1)
	else:
		ans = 0
		if d > 0:
			ans += d
		if e > 0:
			ans += e
		if f > 0:
			ans += f
		print(ans)


def diff(x, y):
	ans = []
	for i in range(3):
		if x[i] > y[i]:
			return -1
		if x[i] != y[i]:
			ans.append(abs(x[i] - y[i]))
	return sum(ans)
for _ in range(int(input())):
	q = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	print(diff(q, a))