Chef is given two arrays A and B of length N each.

In one operation Chef can choose one element of A and one element of B and increase them by 1.

More formally:
Chef can pick two integers i, j (1≤ i, j ≤ N) and increment A_{i} and B_{j} by 1.

Determine the minimum number of operations required to make A and B equal.

Output -1 if it is not possible to make A and B equal.

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of multiple lines of input.
- The first line of each test case contains a single integer N - denoting the length of arrays A and B.
- The second line of each test case contains N space separated integers A_{1}, A_{2}, A_{3}, \dots A_{N} - denoting the array A.
- The third line of each test case contains N space separated integers B_{1}, B_{2}, B_{3}, \dots B_{N} - denoting the array B.

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

For each test case, output the minimum number of operations to make A and B equal or -1 if they cannot be made equal.

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

$1 ≤ T ≤ 2 \cdot 10^{4}$
$2 ≤ N ≤ 10^{5}$
$1 ≤ A_{i}, B_{i} ≤ 10^{9}$
- Sum of $N$ over all test cases do not exceed $10^{5}$.

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

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

----- explanation 1 ------ 
Test case $1$: We can choose $i = 1$ and $j = 2$ and increment $A_{i}$ and $B_{j}$ by $1$. Thus, both arrays become $[2, 2]$ and are equal. We require only $1$ operation to make these arrays equal. It can be proven that the arrays cannot be made equal in less than one operation.

Test case $2$: Both the arrays cannot be made equal using any number of operations.

Test case $3$: We perform $2$ operations as follows:
- Choose $i = 1, j = 3$: The arrays become $A = [5, 6, 8]$ and $B = [5, 7, 7]$.
- Choose $i = 2, j = 3$: The arrays become $A = [5, 7, 8]$ and $B = [5, 7, 8]$.

Thus, both arrays can be made equal using $2$ operations.

Difficulty: EASY

Solutions:
for joe_mama in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	k = []
	for i in range(n):
		k.append(l1[i] - l2[i])
	if sum(k) == 0:
		c = 0
		for i in k:
			if i > 0:
				c += i
		print(c)
	else:
		print('-1')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = ans = 0
	for i in range(n):
		if a[i] > b[i]:
			res += a[i] - b[i]
		else:
			ans += b[i] - a[i]
	if res == ans:
		print(res)
	else:
		print(-1)


t = int(input())
while t > 0:
	sa = 0
	sb = 0
	n = int(input())
	a = []
	b = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(0, n):
		if a[i] > b[i]:
			sa += a[i] - b[i]
		else:
			sb += b[i] - a[i]
	if sa == sb:
		print(sa)
	else:
		print('-1')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	positiveDiff = 0
	negativeDiff = 0
	for i in range(n):
		if a[i] > b[i]:
			positiveDiff += a[i] - b[i]
		elif a[i] < b[i]:
			negativeDiff += b[i] - a[i]
	if positiveDiff == negativeDiff:
		print(positiveDiff)
	else:
		print(-1)


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


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = 0
	y = 0
	for i in range(n):
		x += a[i] - b[i]
		y += abs(a[i] - b[i])
	if x != 0:
		print(-1)
	elif y % 2 != 0:
		print(-1)
	else:
		print(y // 2)


import math
t = int(input())
for xx in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	t = 0
	for i in range(n):
		s += a[i]
		s -= b[i]
		t = t + abs(a[i] - b[i])
	if s == 0:
		print(t // 2)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	for i in range(n):
		if a[i] > b[i]:
			c += a[i] - b[i]
	print(c if sum(a) == sum(b) else -1)


t = int(input())
for i in range(0, t):
	n = int(input())
	p = list(map(int, input().split()))[:n]
	q = list(map(int, input().split()))[:n]
	cnt1 = 0
	cnt2 = 0
	for j in range(n):
		if p[j] > q[j]:
			cnt1 += p[j] - q[j]
		elif p[j] < q[j]:
			cnt2 += q[j] - p[j]
	if cnt1 == cnt2:
		print(cnt1)
	else:
		print('-1')


for t in range(int(input())):
	n = int(input())
	ai = [int(i) for i in input().split()]
	bi = [int(i) for i in input().split()]
	if sum(ai) != sum(bi):
		print(-1)
	else:
		count = 0
		for i in range(n):
			if ai[i] > bi[i]:
				count += ai[i] - bi[i]
		print(count)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:n]
	c1 = 0
	c2 = 0
	for j in range(n):
		if a[j] > b[j]:
			c1 += a[j] - b[j]
		elif a[j] < b[j]:
			c2 += b[j] - a[j]
	if c1 == c2:
		print(c1)
	else:
		print('-1')


y = int(input())
gbt = []
for mmf in range(0, y):
	lpe = int(input())
	ad = str(input())
	pq = str(input())
	jut = ad.split(' ')
	vv = pq.split(' ')
	amb = [jut, vv]
	gbt.append(amb)
for rrr in gbt:
	um = rrr[0]
	unv = rrr[1]
	fxz = 0
	sumd = 0
	for kkxa in range(0, len(um)):
		if int(um[kkxa]) < int(unv[kkxa]):
			fxz += int(unv[kkxa]) - int(um[kkxa])
		elif int(um[kkxa]) > int(unv[kkxa]):
			sumd += int(um[kkxa]) - int(unv[kkxa])
		else:
			continue
	if fxz != sumd:
		print(-1)
	else:
		print(fxz)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = sum(a)
	y = sum(b)
	if x != y:
		print(-1)
	else:
		z = 0
		for i in range(n):
			z += abs(a[i] - b[i])
		print(z // 2)


t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = []
	if sum(l1) != sum(l2):
		print('-1')
	else:
		for i in range(n):
			l3.append(abs(l1[i] - l2[i]))
		s = sum(l3)
		print(s // 2)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ct = 0
	if sum(a) != sum(b):
		print(-1)
	else:
		for i in range(n):
			ct = ct + abs(a[i] - b[i])
		if ct % 2 == 0 or ct == 0:
			print(ct // 2)
		else:
			print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	if sum(a) != sum(b):
		print('-1')
	elif sum(a) == sum(b):
		for i in range(n):
			c.append(abs(a[i] - b[i]))
		print(sum(c) // 2)


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l1 = []
	l2 = []
	for k in range(n):
		if a[k] > b[k]:
			l1.append(a[k] - b[k])
		else:
			l2.append(b[k] - a[k])
	if sum(l1) == sum(l2):
		print(sum(l1))
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	(l1, l2) = ([], [])
	for i in range(n):
		if a[i] <= b[i]:
			l1.append(b[i] - a[i])
		else:
			l2.append(a[i] - b[i])
	if sum(l1) == sum(l2):
		print(sum(l1))
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(x, y) = (0, 0)
	for i in range(n):
		if a[i] > b[i]:
			x += a[i] - b[i]
		else:
			y += b[i] - a[i]
	if x == y:
		print(x)
	else:
		print(-1)


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = 0
	pos = 0
	for i in range(n):
		diff = a[i] - b[i]
		count += diff
		if diff > 0:
			pos += diff
	if count == 0:
		print(pos)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	s1 = sum(arr1)
	s2 = sum(arr2)
	sum_dif = 0
	for i in range(n):
		sum_dif += abs(arr1[i] - arr2[i])
	if s1 != s2:
		print(-1)
	else:
		print(sum_dif // 2)


t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	s1 = sum(l1)
	s2 = sum(l2)
	sd = 0
	for i in range(n):
		sd += abs(l1[i] - l2[i])
	if s1 != s2:
		print(-1)
	else:
		print(sd // 2)


for _ in range(int(input())):
	nq = int(input())
	aq = [int(x) for x in input().split()]
	bq = [int(x) for x in input().split()]
	sum_dif = 0
	for i in range(nq):
		sum_dif += abs(aq[i] - bq[i])
	if sum(aq) != sum(bq):
		print(-1)
	else:
		print(sum_dif // 2)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	sum_dif = 0
	for i in range(n):
		sum_dif += abs(a[i] - b[i])
	if sum(a) != sum(b):
		print(-1)
	else:
		print(sum_dif // 2)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c1, c2) = (0, 0)
	for i in range(len(a)):
		if a[i] <= b[i]:
			c1 += b[i] - a[i]
		else:
			c2 += a[i] - b[i]
	if c1 != c2:
		print(-1)
	else:
		print(c1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if sum(a) == sum(b):
		p = 0
		for i in range(n):
			p += abs(a[i] - b[i])
		print(p // 2)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	count = 0
	count1 = 0
	for j in range(n):
		count += abs(A[j] - B[j])
		count1 += A[j] - B[j]
	if count1 == 0:
		print(count // 2)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	op = list(map(int, input().split(' ')))
	po = list(map(int, input().split(' ')))
	count = 0
	if sum(op) != sum(po):
		print('-1')
	else:
		for i in range(len(op)):
			if op[i] >= po[i]:
				diff = op[i] - po[i]
			else:
				diff = po[i] - op[i]
			count += diff
		print(count // 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt = 0
	for i in range(n):
		cnt += abs(a[i] - b[i])
	print([-1, cnt // 2][sum(a) == sum(b)])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = d = 0
	for i in range(n):
		if a[i] - b[i] > 0:
			c += a[i] - b[i]
		else:
			d += b[i] - a[i]
	if c == d:
		print(d)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	ca = cb = 0
	for j in range(n):
		if l2[j] - l1[j] > 0:
			ca += l2[j] - l1[j]
		else:
			cb += l1[j] - l2[j]
	if ca == cb:
		print(ca)
	else:
		print(-1)


for _ in range(int(input())):
	g = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ca = cb = 0
	for i in range(g):
		if b[i] - a[i] > 0:
			ca += b[i] - a[i]
		else:
			cb += a[i] - b[i]
	if ca == cb:
		print(ca)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if sum(l1) != sum(l2):
		print(-1)
	else:
		c = 0
		for i in range(len(l1)):
			if l1[i] - l2[i] > 0:
				c += l1[i] - l2[i]
		print(c)


t = int(input())
for ni in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	sa = sum(a)
	sb = sum(b)
	if sa != sb:
		print(-1)
	else:
		ca = 0
		cb = 0
		for i in range(n):
			if a[i] > b[i]:
				ca = ca + (a[i] - b[i])
			else:
				cb = cb + (b[i] - a[i])
		print(ca)


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	count = 0
	C = 0
	D = 0
	for i in range(N):
		if A[i] > B[i]:
			C += A[i] - B[i]
		else:
			D += B[i] - A[i]
	if C == D:
		print(C)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		k = 0
		for j in range(n):
			k += abs(a[j] - b[j])
		print(k // 2)


x = int(input())
for i in range(x):
	l = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	if sum(a) != sum(b):
		print(-1)
	else:
		for j in range(l):
			k += abs(a[j] - b[j])
		print((k + 1) // 2)


t = int(input())
for i in range(t):
	n = int(input())
	summ1 = summ2 = 0
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	for i in range(n):
		summ1 += a[i] - b[i]
		summ2 += abs(a[i] - b[i])
	if summ1 == 0:
		print(int(summ2 / 2))
	else:
		print(-1)


T = int(input())
for i in range(T):
	N = int(input())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	L = []
	maxi = 0
	add = 0
	for j in range(N):
		L.append(L1[j] - L2[j])
		add += L[j]
		if L[j] > 0:
			maxi += L[j]
	if add == 0:
		print(maxi)
	else:
		print(-1)


i = int(input())
for i in range(i):
	n = int(input())
	x = [int(x) for x in input().split()]
	y = [int(x) for x in input().split()]
	z = []
	t1 = 0
	t2 = 0
	ans = 0
	for i in x:
		t1 = t1 + i
	for i in y:
		t2 = t2 + i
	if t1 != t2:
		print(-1)
	else:
		for i in range(n):
			a = x[i] - y[i]
			z.append(a)
		for i in z:
			if i > 0:
				ans = ans + i
		print(ans)


test = int(input())
for i in range(test):
	number = int(input())
	List = list(map(int, input().split()))
	List1 = list(map(int, input().split()))
	count = 0
	if sum(List) != sum(List1):
		print('-1')
	else:
		for i in range(len(List)):
			if List[i] >= List1[i]:
				diff = List[i] - List1[i]
			else:
				diff = List1[i] - List[i]
			count = count + diff
		print(count // 2)


t = int(input())
for i in range(t):
	k = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c1, c2) = (0, 0)
	for i in range(0, k):
		if a[i] > b[i]:
			c1 = c1 + a[i] - b[i]
		else:
			c2 = c2 + b[i] - a[i]
	if c1 == c2:
		print(c1)
	else:
		print(-1)


for test in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	l1 = []
	l2 = []
	if sum(A) != sum(B):
		print(-1)
	else:
		for i in range(n):
			check = A[i] - B[i]
			if check < 0:
				l1.append(-check)
		print(sum(l1))


for i in range(int(input())):
	size = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	l = []
	if sum(a) != sum(b):
		print(-1)
	else:
		for i in range(size):
			if a[i] - b[i] < 0:
				l.append(-(a[i] - b[i]))
		print(sum(l))


for i in range(int(input())):
	n = int(input())
	(c1, c2) = (0, 0)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for (x, y) in zip(a, b):
		if x > y:
			c1 += x - y
		elif y > x:
			c2 += y - x
		else:
			pass
	if c1 == c2:
		print(c1)
	else:
		print('-1')


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	tot = 0
	if sum(a) != sum(b):
		print(-1)
	else:
		for i in range(n):
			tot = tot + abs(a[i] - b[i])
		print(tot // 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_add = 0
	b_add = 0
	for i in range(n):
		delta = a[i] - b[i]
		if delta > 0:
			b_add += delta
		else:
			a_add += -delta
	if a_add == b_add:
		print(a_add)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	maxa = maxb = 0
	for j in range(n):
		if a[j] > b[j]:
			maxa += a[j] - b[j]
		elif b[j] > a[j]:
			maxb += b[j] - a[j]
	if maxa == maxb:
		print(maxa)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sums = 0
	maxi = -1000000000
	for j in range(n):
		val = a[j] - b[j]
		sums += val
	if sums == 0:
		cnt = 0
		for i in range(n):
			if a[i] > b[i]:
				cnt += a[i] - b[i]
		print(cnt)
	else:
		print(-1)


t = int(input())
while t > 0:
	n = int(input())
	a1 = list(map(int, input().split(' ')))
	a2 = list(map(int, input().split(' ')))
	da1 = 0
	da2 = 0
	for i in range(n):
		if a1[i] == a2[i]:
			continue
		elif a1[i] > a2[i]:
			da2 += a1[i] - a2[i]
		else:
			da1 += a2[i] - a1[i]
	if da1 != da2:
		print(-1)
	else:
		print(da1)
	t -= 1


a = int(input(''))
for i in range(a):
	x = int(input(''))
	t1 = [int(x) for x in input('').split()]
	t2 = [int(x) for x in input('').split()]
	p = 0
	q = 0
	for j in range(x):
		if t2[j] - t1[j] > 0:
			p = p + (t2[j] - t1[j])
		else:
			q = q + (t1[j] - t2[j])
	if p == q:
		print(p)
	else:
		print(-1)


for x in range(int(input())):
	n = int(input())
	Li = list(map(int, input().split()))
	Lj = list(map(int, input().split()))
	Diffi = Diffj = 0
	for i in range(n):
		if Lj[i] - Li[i] > 0:
			Diffi += Lj[i] - Li[i]
		else:
			Diffj += Li[i] - Lj[i]
	if Diffi == Diffj:
		print(Diffi)
	else:
		print(-1)


r = int(input())
while r > 0:
	r = r - 1
	n = int(input())
	s = list(map(int, input('').split()))
	w = list(map(int, input().split()))
	ss = sum(s)
	sw = sum(w)
	if ss != sw:
		print(-1)
	else:
		c = 0
		for i in range(n):
			c = c + abs(s[i] - w[i])
		print(c // 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	pos = []
	s = 0
	for i in range(n):
		x = a[i] - b[i]
		if x >= 0:
			pos.append(x)
		s += x
	if s == 0:
		print(sum(pos))
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	m = max(max(x), max(y))
	if sum(x) != sum(y):
		print(-1)
		continue
	op = 0
	for i in range(n):
		op += abs(x[i] - y[i])
	print(op // 2)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	s = 0
	for i in range(n):
		if a[i] < b[i]:
			f = f + (b[i] - a[i])
		if a[i] > b[i]:
			s = s + (a[i] - b[i])
	if f == s:
		print(s)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sum = 0
	op = 0
	for i in range(n):
		diff = a[i] - b[i]
		sum += diff
		op += abs(diff)
	if sum == 0:
		print(int(op / 2))
	else:
		print('-1')


for _ in range(int(input())):
	input()
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if sum(arr1) != sum(arr2):
		print(-1)
	else:
		ans = 0
		for i in range(len(arr1)):
			ans += abs(arr1[i] - arr2[i])
		print(ans // 2)


for x in range(int(input())):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	z = [a[i] - b[i] for i in range(len(a))]
	print(sum([i for i in z if i > 0]) if sum(z) == 0 else -1)


for i in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	l = list(map(int, input().split()))
	count = 0
	if sum(m) == sum(l):
		for i in range(n):
			if m[i] > l[i]:
				diff = m[i] - l[i]
				count = count + diff
		print(count)
	else:
		print('-1')


temp = int(input())
for T in range(temp):
	X1 = 0
	Y1 = 0
	N = int(input())
	X2 = list(map(int, input().split(' ')))
	Y2 = list(map(int, input().split(' ')))
	for i in range(N):
		if X2[i] - Y2[i] > 0:
			X1 = X1 + X2[i] - Y2[i]
		elif X2[i] - Y2[i] < 0:
			Y1 = Y1 + abs(X2[i] - Y2[i])
	if X1 == Y1:
		print(X1)
	else:
		print(-1)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = []
	b1 = []
	for i in a:
		for j in b:
			if i - j < 0:
				b1.append(j - i)
			elif i - j > 0:
				a1.append(i - j)
			b.pop(0)
			break
	if sum(a1) == sum(b1):
		print(sum(a1))
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	l = []
	if sum(A) != sum(B):
		print(-1)
	else:
		for i in range(n):
			l.append(abs(A[i] - B[i]))
		print(int(sum(l) / 2))