In Berland each high school student is characterized by academic performance — integer value between 1 and 5.

In high school 0xFF there are two groups of pupils: the group A and the group B. Each group consists of exactly n students. An academic performance of each student is known — integer value between 1 and 5.

The school director wants to redistribute students between groups so that each of the two groups has the same number of students whose academic performance is equal to 1, the same number of students whose academic performance is 2 and so on. In other words, the purpose of the school director is to change the composition of groups, so that for each value of academic performance the numbers of students in both groups are equal.

To achieve this, there is a plan to produce a series of exchanges of students between groups. During the single exchange the director selects one student from the class A and one student of class B. After that, they both change their groups.

Print the least number of exchanges, in order to achieve the desired equal numbers of students for each academic performance.


-----Input-----

The first line of the input contains integer number n (1 ≤ n ≤ 100) — number of students in both groups.

The second line contains sequence of integer numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 5), where a_{i} is academic performance of the i-th student of the group A.

The third line contains sequence of integer numbers b_1, b_2, ..., b_{n} (1 ≤ b_{i} ≤ 5), where b_{i} is academic performance of the i-th student of the group B.


-----Output-----

Print the required minimum number of exchanges or -1, if the desired distribution of students can not be obtained.


-----Examples-----
Input
4
5 4 4 4
5 5 4 5

Output
1

Input
6
1 1 1 1 1 1
5 5 5 5 5 5

Output
3

Input
1
5
3

Output
-1

Input
9
3 2 5 5 2 3 3 3 2
4 1 4 1 1 2 4 4 1

Output
4

Difficulty: EASY

Solutions:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
swaps = 0
for i in range(1, 6):
	a_count = a.count(i)
	b_count = b.count(i)
	diff = abs(a_count - b_count)
	if diff % 2 != 0:
		swaps = -2
		break
	swaps += diff // 2
print(swaps // 2)


n = int(input())
l_s1 = [0 for i in range(5)]
l_s2 = [0 for i in range(5)]
l_d = [0 for i in range(5)]
for i in list(map(int, input().split())):
	l_s1[i - 1] += 1
for i in list(map(int, input().split())):
	l_s2[i - 1] += 1
for i in range(5):
	l_d[i] = abs(l_s1[i] - l_s2[i])
	if l_d[i] % 2 == 1:
		print(-1)
		quit()
	else:
		l_d[i] //= 2
if sum(l_d) % 2 == 1:
	print(-1)
	quit()
else:
	print(sum(l_d) // 2)


n = int(input())
linea = list(map(int, input().split()))
lineb = list(map(int, input().split()))
lines = linea + lineb
c1 = lines.count(1)
c2 = lines.count(2)
c3 = lines.count(3)
c4 = lines.count(4)
c5 = lines.count(5)
cc1 = linea.count(1)
cc2 = linea.count(2)
cc3 = linea.count(3)
cc4 = linea.count(4)
cc5 = linea.count(5)
if c1 % 2 == 1 or c2 % 2 == 1 or c3 % 2 == 1 or (c4 % 2 == 1) or (c5 % 2 == 1):
	print(-1)
else:
	print(int(abs(c1 / 2 - cc1) + abs(c2 / 2 - cc2) + abs(c3 / 2 - cc3) + abs(c4 / 2 - cc4) + abs(c5 / 2 - cc5)) // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0, 0, 0, 0, 0, 0]
t = False
for i in range(1, 6):
	c[i] += a.count(i) + b.count(i)
	if c[i] % 2:
		t = True
		break
if t:
	print(-1)
else:
	answer = 0
	(a1, b1) = (0, 0)
	for i in range(1, 6):
		a1 += abs(c[i] / 2 - a.count(i))
	print(int(a1 // 2))


n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
(fa, fb) = ([0] * 6, [0] * 6)
for i in range(n):
	fa[a[i]] += 1
	fb[b[i]] += 1
total = 0
for (i, j) in zip(fa, fb):
	if (i + j) % 2:
		exit(print(-1))
	total += abs(i - j) // 2
print(total // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [0] * 6
b1 = [0] * 6
for i in a:
	a1[i] += 1
for i in b:
	b1[i] += 1
ans = 0
for i in range(1, 6):
	if (a1[i] + b1[i]) % 2 != 0:
		ans = -1
		break
	ans += (max(a1[i], b1[i]) - min(a1[i], b1[i])) // 2
if ans == -1:
	print(-1)
else:
	print(ans // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = [0] * 6
d2 = [0] * 6
for i in range(n):
	d1[a[i]] += 1
	d2[b[i]] += 1
diff1 = 0
diff2 = 0
for i in range(6):
	if (d1[i] + d2[i]) % 2 != 0:
		print(-1)
		exit()
	if d1[i] - d2[i] > 0:
		diff1 += abs(d1[i] - d2[i])
	else:
		diff2 += abs(d1[i] - d2[i])
if diff1 == diff2 and diff1 % 2 == 0:
	print(diff1 // 2)
else:
	print(-1)


def f():
	n = int(input())
	a = [0] * 5
	b = [0] * 5
	X = [int(x) for x in input().split()]
	for x in X:
		a[x - 1] += 1
	X = [int(x) for x in input().split()]
	for x in X:
		b[x - 1] += 1
	for i in range(5):
		if (a[i] + b[i]) % 2 == 1:
			print('-1')
			return
	x = 0
	for i in range(5):
		x += abs(a[i] - b[i]) / 2
	print(int(x / 2))
f()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c1 = [0, 0, 0, 0, 0, 0, 0]
c2 = [0, 0, 0, 0, 0, 0, 0]
for i in a:
	c1[i] += 1
for i in b:
	c2[i] += 1
for i in range(6):
	if (c1[i] + c2[i]) % 2 == 1:
		print(-1)
		break
else:
	ans = 0
	for i in range(6):
		ans += abs(c1[i] - c2[i])
	print(ans // 4)


import sys
inf = float('inf')
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
n = int(input())
A = get_array()
B = get_array()
mydict_A = dict()
mydict_B = dict()
for (i, j) in zip(A, B):
	mydict_A[i] = mydict_A.get(i, 0) + 1
	mydict_B[j] = mydict_B.get(j, 0) + 1
score = [0] * 6
for (i, j) in zip(A, B):
	score[i] += 1
	score[j] += 1
flag = 0
for i in range(1, 6):
	if score[i] & 1:
		flag = 1
		break
if flag == 1:
	print(-1)
	exit(0)
contri_A = 0
contri_B = 0
for i in mydict_A:
	contri_A += max(mydict_A[i] - score[i] / 2, 0)
for i in mydict_B:
	contri_B += max(mydict_B[i] - score[i] / 2, 0)
if contri_A != contri_B:
	print(-1)
	exit(0)
print(int(contri_A))


import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
special = 0
lcng = rcng = 0
for j in range(1, 6):
	l = a.count(j)
	r = b.count(j)
	if l != r:
		if l == 1 and r == 0 or (r == 1 and l == 0) or (l + r) % 2 != 0:
			special = 1
		elif l > r and special != 1:
			lcng += int(l - (l + r) / 2)
		else:
			rcng += int(r - (l + r) / 2)
if lcng != rcng or special == 1:
	print('-1')
else:
	print(lcng)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(d1, d2) = ({1: 0, 2: 0, 3: 0, 4: 0, 5: 0}, {1: 0, 2: 0, 3: 0, 4: 0, 5: 0})
for i in range(n):
	d1[a[i]] += 1
	d2[b[i]] += 1
(a, b, f) = (0, 0, 0)
for i in range(1, 6):
	if d1[i] >= d2[i]:
		w = d1[i] + d2[i]
		if w & 1:
			f = 1
			break
		else:
			a += d1[i] - w // 2
	else:
		w = d1[i] + d2[i]
		if w & 1:
			f = 1
			break
		else:
			b += d2[i] - w // 2
if f == 0 and a == b:
	print(a)
else:
	print(-1)


n = int(input())
a = input()
b = input()
q = (a + b).count('1')
w = (a + b).count('2')
e = (a + b).count('3')
r = (a + b).count('4')
t = (a + b).count('5')
y = a.count('1')
u = a.count('2')
o = a.count('3')
p = a.count('4')
s = a.count('5')
if any([x % 2 != 0 for x in [q, w, e, r, t]]):
	print(-1)
else:
	print(int((abs(int(q / 2) - y) + abs(int(w / 2) - u) + abs(int(e / 2) - o) + abs(int(r / 2) - p) + abs(int(t / 2) - s)) / 2))


n = int(input())
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))

def count(a, listt):
	l = 0
	for i in range(0, len(listt)):
		if a == listt[i]:
			l += 1
	return l
x = True
l = 0
for i in range(1, 6):
	if (count(i, c1) + count(i, c2)) % 2 == 0:
		l += abs(count(i, c1) - count(i, c2))
	else:
		print(-1)
		x = False
		break
if x == True:
	print(l // 4)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = 0
c = 0
for i in range(1, 6):
	x = a.count(i)
	y = b.count(i)
	if (x + y) % 2 == 0:
		s = s + abs(x - y) // 2
	else:
		c = 1
		break
if c == 1:
	print(-1)
else:
	print(s // 2)


import sys

def main():
	n = int(input())
	c1 = [0] * 6
	c2 = [0] * 6
	for i in input().split():
		c1[int(i)] += 1
	for i in input().split():
		c2[int(i)] += 1
	ans = 0
	for i in range(6):
		if (c1[i] + c2[i]) % 2 == 1:
			print(-1)
			return
		ans += abs((c1[i] + c2[i]) // 2 - c1[i])
	print(ans // 2)
_fin = sys.stdin
_fout = sys.stdout
if 'ANDREIKKAA' in sys.argv:
	_fin = open('input.txt', 'r')
	pass
else:
	pass
if _fin:
	sys.stdin = _fin
if _fout:
	sys._stdout = _fout
main()


n = int(input())
adata = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
bdata = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
a = list(map(int, input().split()))
for x in a:
	adata[x] = adata[x] + 1
b = list(map(int, input().split()))
for x in b:
	bdata[x] = bdata[x] + 1
ans = 0
ans = ans + abs(adata[1] - bdata[1])
ans = ans + abs(adata[2] - bdata[2])
ans = ans + abs(adata[3] - bdata[3])
ans = ans + abs(adata[4] - bdata[4])
ans = ans + abs(adata[5] - bdata[5])
if (adata[1] + bdata[1]) % 2 != 0 or (adata[1] + bdata[1]) % 2 != 0 or (adata[2] + bdata[2]) % 2 != 0 or ((adata[3] + bdata[3]) % 2 != 0) or ((adata[4] + bdata[4]) % 2 != 0) or ((adata[5] + bdata[5]) % 2 != 0):
	ans = -1
print(ans // 4)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnta = [0 for i in range(0, 6)]
cntb = [0 for i in range(0, 6)]
for i in range(0, n):
	cnta[a[i]] += 1
	cntb[b[i]] += 1
flag = 0
for i in range(1, 6):
	if (cnta[i] + cntb[i]) % 2 == 1:
		flag = 1
if flag:
	print('-1')
else:
	ans = 0
	for i in range(1, 6):
		val = (cnta[i] + cntb[i]) / 2
		if cnta[i] > val:
			ans += cnta[i] - val
	print(int(ans))


import sys
n = int(input())
g1 = list(map(int, input().split()))
g2 = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
	n1 = g1.count(i)
	n2 = g2.count(i)
	if abs(n1 - n2) % 2 != 0:
		print(-1)
		sys.exit()
	ans += abs(n1 - n2) // 2
print(ans // 2)


import sys
import math
from sys import stdin, stdout

def get_ints_in_variables():
	return map(int, sys.stdin.readline().strip().split())

def get_ints_in_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def Solution(arr1, arr2, n):
	cnt = [0 for _ in range(6)]
	for v in arr1:
		cnt[v] += 1
	for u in arr2:
		cnt[u] -= 1
	ans = 0
	for c in cnt:
		if c % 2 != 0:
			print(-1)
			return
		else:
			ans += abs(c)
	print(ans // 4)

def main():
	n = int(input())
	arr1 = get_ints_in_list()
	arr2 = get_ints_in_list()
	Solution(arr1, arr2, n)
main()


n = int(input())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
c = [0] * 8
ans = 0
for i in l:
	c[i] += 1
for i in l1:
	c[i] -= 1
for i in range(6):
	if c[i] % 2:
		print(-1)
		break
	ans += abs(c[i]) // 2
else:
	print(ans // 2)


n = int(input())
a = list(sorted(map(int, input().split())))
b = list(sorted(map(int, input().split())))
s = []
ei = 0
for i in range(5):
	t = [a.count(i + 1), b.count(i + 1)]
	s.append(t[0] - t[1])
	if sum(t) % 2 == 1:
		ei = 1
if bool(ei):
	print(-1)
else:
	print(int(sum(filter(lambda x: x > 0, s)) / 2))


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
countsofa = [0 for i in range(5)]
countsofb = [0 for i in range(5)]
totalcount = [0 for i in range(5)]
for i in range(len(a)):
	countsofa[a[i] - 1] += 1
for i in range(len(b)):
	countsofb[b[i] - 1] += 1
for i in range(len(countsofa)):
	totalcount[i] = countsofa[i] + countsofb[i]
temp = 1
for i in range(len(totalcount)):
	if totalcount[i] % 2 != 0:
		temp = 0
		break
if temp == 0:
	print('-1')
else:
	ans = 0
	for i in range(len(countsofa)):
		if countsofa[i] >= countsofb[i]:
			ans = ans + totalcount[i] / 2 - countsofb[i]
		else:
			ans = ans + totalcount[i] / 2 - countsofa[i]
	print(int(ans / 2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = [0 for i in range(5)]
bb = [0 for i in range(5)]
cc = [0 for i in range(5)]
for i in range(n):
	aa[a[i] - 1] += 1
	cc[a[i] - 1] += 1
for i in range(n):
	bb[b[i] - 1] += 1
	cc[b[i] - 1] += 1
f = True
for i in range(5):
	if cc[i] % 2 != 0:
		f = False
		break
	else:
		cc[i] //= 2
if not f:
	print(-1)
else:
	o = 0
	for i in range(5):
		o += abs(cc[i] - aa[i])
	print(o // 2)


ans = 0
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
x = {i: 0 for i in range(1, 6)}
y = {i: 0 for i in range(1, 6)}
for i in a:
	x[i] += 1
for i in b:
	y[i] += 1
ans = [0] * 2
for i in range(1, 6):
	tmp = x[i] - y[i]
	if tmp % 2 != 0:
		print(-1)
		exit()
	elif tmp > 0:
		ans[1] += tmp
	else:
		ans[0] += tmp
print(ans[1] // 2 if sum(ans) == 0 else -1)


input()
A = [0] * 5
B = [0] * 5
L1 = list(map(int, input().split()))
L2 = list(map(int, input().split()))
for a in L1:
	A[a - 1] += 1
for b in L2:
	B[b - 1] += 1
toA = 0
f = True
for i in range(5):
	if (A[i] + B[i]) % 2 == 1:
		f = False
		break
	elif B[i] > A[i]:
		toA += B[i] - (A[i] + B[i]) // 2
if not f:
	print(-1)
else:
	print(toA)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = [0] * 5
	balance = [0] * 5
	for e in a:
		count[e - 1] += 1
		balance[e - 1] += 1
	for e in b:
		count[e - 1] += 1
		balance[e - 1] -= 1
	for e in count:
		if e % 2 != 0:
			print(-1)
			return
	print(sum([abs(i) for i in balance]) // 4)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
a_dict = {i: 0 for i in range(1, 6)}
b_dict = {i: 0 for i in range(1, 6)}
for s in a:
	if s in a_dict:
		a_dict[s] += 1
	else:
		a_dict[s] = 1
for t in b:
	if t in b_dict:
		b_dict[t] += 1
	else:
		b_dict[t] = 1
ans = 0
for i in range(1, 6):
	if (a_dict[i] + b_dict[i]) % 2 == 1:
		ans = -2
		break
	else:
		ans += abs((a_dict[i] + b_dict[i]) // 2 - a_dict[i])
ans = ans // 2
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
for x in a:
	d[x] = d.get(x, 0) + 1
for x in b:
	d[x] = d.get(x, 0) - 1
ans = 0
cnt = 0
for (k, v) in d.items():
	ans += abs(v)
	cnt += v % 2
if cnt > 0:
	print(-1)
else:
	print(ans // 4)


n = int(input())
x = [int(q) for q in input().split()]
y = [int(w) for w in input().split()]
o = x.count(1)
t = x.count(2)
th = x.count(3)
f = x.count(4)
fi = x.count(5)
o1 = y.count(1)
t1 = y.count(2)
th1 = y.count(3)
f1 = y.count(4)
fi1 = y.count(5)
if abs(o - o1) % 2 != 0 or abs(t - t1) % 2 != 0 or abs(th - th1) % 2 != 0 or (abs(f - f1) % 2 != 0) or (abs(fi - fi1) % 2 != 0):
	print(-1)
elif (abs(o - o1) + abs(t - t1) + abs(th - th1) + abs(f - f1) + abs(fi - fi1)) % 2 != 0:
	print(-1)
else:
	ans = abs(o - o1) + abs(t - t1) + abs(th - th1) + abs(f - f1) + abs(fi - fi1)
	print(ans // 4)


n = int(input())
c1 = list(map(int, input().split(' ')))
c2 = list(map(int, input().split(' ')))
m1_add = []
m1_rem = []
m2_add = []
m2_rem = []
boolean = True
for i in range(1, 6):
	k1 = c1.count(i)
	k2 = c2.count(i)
	if abs(k1 - k2) % 2 == 1:
		print(-1)
		boolean = False
		break
	if k1 > k2:
		m1_rem.append((k1 - k2) // 2)
		m2_rem.append(0)
		m1_add.append(0)
		m2_add.append((k1 - k2) // 2)
	else:
		m1_rem.append(0)
		m2_rem.append((k2 - k1) // 2)
		m1_add.append((k2 - k1) // 2)
		m2_add.append(0)
if boolean:
	for i in range(5):
		for j in range(m1_add[i]):
			c1.append(i + 1)
		for j in range(m2_add[i]):
			c2.append(i + 1)
		for j in range(m1_rem[i]):
			c1.remove(i + 1)
		for j in range(m2_rem[i]):
			c2.remove(i + 1)
	if sum([int(i) for i in c1]) == sum([int(i) for i in c2]):
		print(sum(m1_add))
	else:
		print(-1)


l = [0] * 5
q = [0] * 5
G = 0
w = []
n = int(input())
p = input().rstrip().split(' ')
r = input().rstrip().split(' ')
for i in range(0, len(p)):
	l[int(p[i]) - 1] += 1
for i in range(0, len(r)):
	q[int(r[i]) - 1] += 1
S = []
for i in range(0, len(l)):
	if (l[i] + q[i]) % 2 != 0:
		G = 1
		break
	else:
		S.append((l[i] + q[i]) // 2)
if G == 1:
	print(-1)
else:
	D = 0
	for i in range(0, len(l)):
		if l[i] != q[i]:
			if l[i] > q[i]:
				g = S[i] - q[i]
				l[i] -= g
				q[i] += g
				w.append(g)
			else:
				g = S[i] - l[i]
				q[i] = q[i] - g
				l[i] += g
				w.append(g)
	for i in range(0, len(w)):
		D += w[i]
	print(D // 2)


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
s1 = [0 for x in range(6)]
for i in l1:
	s1[i] += 1
s2 = [0 for x in range(6)]
for i in l2:
	s2[i] += 1
tot = 0
for i in range(1, 6):
	if (s1[i] + s2[i]) % 2 != 0:
		print(-1)
		exit(0)
for i in range(1, 6):
	tot += abs(s1[i] - s2[i])
print(tot // 4)


read = lambda : map(int, input().split())
n = int(input())
a = sorted(read())
b = sorted(read())
for i in range(1, 6):
	if (a.count(i) + b.count(i)) % 2:
		print(-1)
		exit()
cnt = 0
while 1:
	flag = False
	for i in range(n):
		if a.count(a[i]) > b.count(a[i]):
			for j in range(n):
				if a.count(b[j]) < b.count(b[j]) and a[i] != b[j]:
					(a[i], b[j]) = (b[j], a[i])
					cnt += 1
					break
			if flag:
				break
	if not flag:
		break
print(cnt)


n = int(input())
a = [0, 0, 0, 0, 0]
(*q,) = map(int, input().split())
(*w,) = map(int, input().split())
for i in range(5):
	a[i] = q.count(i + 1)
	a[i] -= w.count(i + 1)
	if a[i] % 2:
		print(-1)
		break
else:
	print(sum([abs(i // 2) for i in a]) // 2)


import math, sys

def main():
	n = int(input())
	a = map(int, input().split())
	b = map(int, input().split())
	a5 = 0
	a4 = 0
	a3 = 0
	a2 = 0
	a1 = 0
	b5 = 0
	b4 = 0
	b3 = 0
	b2 = 0
	b1 = 0
	ans = 0
	for i in a:
		if i == 5:
			a5 += 1
		if i == 4:
			a4 += 1
		if i == 3:
			a3 += 1
		if i == 2:
			a2 += 1
		if i == 1:
			a1 += 1
	for i in b:
		if i == 5:
			b5 += 1
		if i == 4:
			b4 += 1
		if i == 3:
			b3 += 1
		if i == 2:
			b2 += 1
		if i == 1:
			b1 += 1
	if (a5 + b5) % 2 == 0 and (a4 + b4) % 2 == 0 and ((a3 + b3) % 2 == 0) and ((a2 + b2) % 2 == 0) and ((a1 + b1) % 2 == 0):
		ans += max(a5, b5) - (a5 + b5) // 2
		ans += max(a4, b4) - (a4 + b4) // 2
		ans += max(a3, b3) - (a3 + b3) // 2
		ans += max(a2, b2) - (a2 + b2) // 2
		ans += max(a1, b1) - (a1 + b1) // 2
		print(ans // 2)
		sys.exit(0)
	print(-1)
main()


n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
(A, B) = ([0] * 6, [0] * 6)
for i in range(n):
	A[arr[i]] += 1
	B[brr[i]] += 1
tot = 0
(a, b) = (0, 0)
for i in range(6):
	if A[i] + B[i] & 1 == 1:
		print('-1')
		break
	if A[i] > B[i]:
		a += (A[i] - B[i]) // 2
	else:
		b += (B[i] - A[i]) // 2
else:
	if a == b:
		print(a)
	else:
		print(-1)


n = int(input())
a = [0 for x in range(6)]
b = a.copy()
for i in input().split(' '):
	a[int(i)] += 1
for i in input().split(' '):
	b[int(i)] += 1
flag = False
res = 0
for i in range(1, 6):
	temp = a[i] - b[i]
	if temp % 2:
		flag = True
		break
	if temp > 0:
		res += temp
print(-1) if flag == True else print(res // 2)


from collections import Counter as c
input()
a = c(map(int, input().split()))
b = c(map(int, input().split()))
d = c()
for i in range(1, 6):
	d[i] = abs(a[i] - b[i])
e = True
for i in range(1, 6):
	if d[i] % 2:
		e = False
		print(-1)
		break
if e:
	print(sum((d[i] for i in range(1, 6))) // 4)


from collections import Counter
n = int(input())
a = Counter(input().split())
b = Counter(input().split())
c = a + b
s = 0
for i in c:
	if c[i] % 2:
		print(-1)
		exit(0)
	else:
		s += abs(a[i] - b[i])
print(s // 4)


x = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = a + b
t = list(set(s))
k = 0
k1 = 0
flag = 0
d = {}
for i in range(len(t)):
	r = a.count(t[i])
	r1 = b.count(t[i])
	if (r - r1) % 2 == 1 or (r1 - r) % 2 == 1:
		print(-1)
		flag = 1
		break
	elif r > r1:
		k = k + r - r1
	else:
		k1 = k1 + r1 - r
if k % 2 == 0 and k == k1 and (flag == 0):
	print(k // 2)
elif flag == 0:
	print(-1)


n = int(input())
l1 = [int(x) for x in input().split()]
l2 = [int(x) for x in input().split()]
a1 = a2 = b1 = b2 = c1 = c2 = d1 = d2 = e1 = e2 = 0
for i in range(len(l1)):
	if l1[i] == 1:
		a1 += 1
	elif l1[i] == 2:
		b1 += 1
	elif l1[i] == 3:
		c1 += 1
	elif l1[i] == 4:
		d1 += 1
	else:
		e1 += 1
	if l2[i] == 1:
		a2 += 1
	elif l2[i] == 2:
		b2 += 1
	elif l2[i] == 3:
		c2 += 1
	elif l2[i] == 4:
		d2 += 1
	else:
		e2 += 1
if (a1 + a2) % 2 != 0 or (b1 + b2) % 2 != 0 or (c1 + c2) % 2 != 0 or ((d1 + d2) % 2 != 0) or ((e1 + e2) % 2 != 0):
	print(-1)
else:
	m = 0
	if a1 > a2:
		m += a1 - a2
	if b1 > b2:
		m += b1 - b2
	if c1 > c2:
		m += c1 - c2
	if d1 > d2:
		m += d1 - d2
	if e1 > e2:
		m += e1 - e2
	print(m // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
total = 0
for i in range(1, 6):
	(aCnt, bCnt) = (a.count(i), b.count(i))
	if (aCnt + bCnt) % 2:
		total = -2
		break
	else:
		total += abs(aCnt - bCnt) // 2
print(total // 2)


n = int(input())
first = tuple(map(int, input().split(' ')))
second = tuple(map(int, input().split(' ')))
answer = 0
for el in range(1, 6):
	if (first.count(el) + second.count(el)) % 2:
		answer = -1
if answer != -1:
	for el in range(1, 6):
		answer += abs(first.count(el) - (first.count(el) + second.count(el)) / 2)
	answer = int(answer / 2)
print(answer)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cnt = [0] * 5
for elem in A:
	cnt[elem - 1] += 1
for elem in B:
	cnt[elem - 1] += 1
bad = 0
for elem in cnt:
	bad += elem % 2
if bad != 0:
	print(-1)
else:
	cntA = [0] * 5
	cntB = [0] * 5
	for elem in A:
		cntA[elem - 1] += 1
	for elem in B:
		cntB[elem - 1] += 1
	ans = 0
	for i in range(5):
		ans += abs(cntA[i] - cntB[i]) // 2
	print(ans // 2)


def pupils(n, lst1, lst2):
	count = 0
	(c, d) = ([0] * 6, [0] * 6)
	for i in range(n):
		c[lst1[i]] += 1
		d[lst1[i]] += 1
		c[lst2[i]] -= 1
		d[lst2[i]] -= 1
	for i in range(len(d)):
		if d[i] & 1:
			return -1
		count += abs(c[i])
	return count // 4
n = int(input())
a = [int(j) for j in input().split()]
b = [int(z) for z in input().split()]
print(pupils(n, a, b))


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


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
totalcount = [0 for i in range(6)]
acount = [0 for i in range(6)]
bcount = [0 for i in range(6)]
for x in a:
	totalcount[x] += 1
	acount[x] += 1
for x in b:
	totalcount[x] += 1
	bcount[x] += 1
possible = True
for x in totalcount:
	if x % 2 == 1:
		possible = False
		break
countswitches = 0
for i in range(1, 6):
	if acount[i] > bcount[i]:
		countswitches += abs(acount[i] - bcount[i]) // 2
if possible:
	print(countswitches)
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = {}
for x in a:
	cnt[x] = cnt.get(x, 0) + 1
for x in b:
	cnt[x] = cnt.get(x, 0) - 1
if any([abs(v) % 2 == 1 for v in cnt.values()]):
	print(-1)
else:
	ans = sum([v for v in cnt.values() if v > 0]) // 2
	print(ans)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(da, db) = ({}, {})
for x in a:
	da[x] = da.get(x, 0) + 1
for x in b:
	db[x] = db.get(x, 0) + 1
ansa = 0
for key in da:
	v = da[key] + db.get(key, 0)
	if v % 2 != 0:
		ansa = -1
		break
	elif da[key] > v // 2:
		ansa += da[key] - v // 2
ansb = 0
for key in db:
	v = db[key] + da.get(key, 0)
	if v % 2 != 0:
		ansb = -1
		break
	elif db[key] > v // 2:
		ansb += db[key] - v // 2
if ansa != ansb:
	print(-1)
else:
	print(ansa)


n = int(input())
a = [int(s) for s in input().split()]
b = [int(s) for s in input().split()]
oz1 = []
oz2 = []
for i in range(1, 6):
	oz1.append((a.count(i) + b.count(i)) % 2)
	oz2.append((a.count(i) + b.count(i)) // 2)
if 1 in oz1:
	print(-1)
else:
	rez = 0
	for i in range(1, 6):
		if a.count(i) > oz2[i - 1]:
			rez += a.count(i) - oz2[i - 1]
	print(rez)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
for i in range(1, 6):
	x = a.count(i)
	y = b.count(i)
	if (x + y) % 2 == 0:
		res += abs(x - y) // 2
	else:
		exit(print(-1))
print(res // 2)


import sys
from collections import Counter
n = int(input())
a = Counter(map(int, input().split()))
b = Counter(map(int, input().split()))
counta = 0
countb = 0
for i in range(1, 5 + 1):
	diff = abs(a[i] - b[i])
	if diff % 2:
		print(-1)
		sys.exit(0)
	if a[i] < b[i]:
		countb += int(diff / 2)
	if b[i] < a[i]:
		counta += int(diff / 2)
if counta != countb:
	print(-1)
	sys.exit(0)
print(counta)


from collections import Counter
n = int(input())
c1 = Counter([int(x) for x in input().split()])
c2 = Counter([int(x) for x in input().split()])
s = 0
for i in range(1, 6):
	d = abs(c1.get(i, 0) - c2.get(i, 0))
	if d % 2:
		print(-1)
		exit()
	s += d // 2
print(s // 2)


n = int(input())
groupA = list(map(int, input().split()))
groupB = list(map(int, input().split()))

def num_switches(n, groupA, groupB):
	diff = [0, 0, 0, 0, 0]
	for score in range(1, 6):
		if abs(groupA.count(score) - groupB.count(score)) % 2 == 1:
			return -1
		else:
			diff[score - 1] = abs(groupA.count(score) - groupB.count(score))
	if sum(diff) % 4 != 0:
		return -1
	else:
		return sum(diff) // 4
print(num_switches(n, groupA, groupB))


n = int(input())
groupA = [int(x) for x in input().split()]
groupB = [int(x) for x in input().split()]
a = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
b = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
ans = 0
for i in range(n):
	a[groupA[i]] += 1
	b[groupB[i]] += 1
for i in a.keys():
	if (a[i] + b[i]) % 2 != 0:
		print(-1)
		exit()
	ans += abs(int((a[i] + b[i]) / 2) - a[i])
print(int(ans / 2))


n = int(input())
a = [int(inp) for inp in input().split()]
b = [int(inp) for inp in input().split()]
dictionary = [0] * 6
for num in a:
	dictionary[num] += 1
for num in b:
	dictionary[num] -= 1
count = 0
for num in dictionary:
	if abs(num) % 2 != 0:
		count = -1
		break
	else:
		count += max(0, num)
print(count // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [a.count(i) for i in range(1, 6)]
B = [b.count(i) for i in range(1, 6)]
cnt = 0
for j in range(5):
	if (A[j] + B[j]) % 2 != 0:
		print(-1)
		exit()
	cnt += abs(A[j] - B[j])
print(cnt // 4)


n = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
freq = [0] * 6
freq_a = [0] * 6
freq_b = [0] * 6
for i in A:
	freq[i] += 1
	freq_a[i] += 1
for i in B:
	freq[i] += 1
	freq_b[i] += 1
ans = 0
for i in range(1, 6):
	if freq[i] % 2:
		print(-1)
		exit()
	ans += abs(freq_a[i] - freq_b[i]) // 2
print(ans // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if (a.count(1) + b.count(1)) % 2 != 0 or (a.count(2) + b.count(2)) % 2 != 0 or (a.count(3) + b.count(3)) % 2 != 0 or ((a.count(4) + b.count(4)) % 2 != 0) or ((a.count(5) + b.count(5)) % 2 != 0):
	print(-1)
else:
	k = 0
	k += abs(a.count(1) - b.count(1)) // 2
	k += abs(a.count(2) - b.count(2)) // 2
	k += abs(a.count(3) - b.count(3)) // 2
	k += abs(a.count(4) - b.count(4)) // 2
	k += abs(a.count(5) - b.count(5)) // 2
	print(k // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
exchanges = 0
A = [0] * 5
for x in a:
	A[x - 1] += 1
B = [0] * 5
for x in b:
	B[x - 1] += 1
for x in range(5):
	if (A[x] + B[x]) % 2 == 1:
		exchanges = -1
		break
if exchanges != -1:
	total = 0
	for x in range(5):
		total += abs(A[x] - B[x])
	total = total // 4
	exchanges = total
print(exchanges)


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
n = INT()
a = LIST()
b = LIST()
freq1 = [0] * 6
freq2 = [0] * 6
for i in a:
	freq1[i] += 1
for i in b:
	freq2[i] += 1
c = a + b
c2 = Counter(c)
c3 = c2.values()
flag = True
for i in c3:
	if i % 2 != 0:
		flag = False
		break
if not flag:
	print('-1')
	exit()
ans = 0
for i in range(1, 5 + 1):
	z = abs(freq1[i] - freq2[i]) // 2
	ans += z
print(ans // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = [0 for x in range(100)]
for x in a:
	count[x] += 1
for x in b:
	count[x] -= 1
for x in range(100):
	if count[x] < 0:
		count[x] = abs(count[x])
	if count[x] % 2 != 0:
		print(-1)
		exit()
total = sum(count) // 2
if total % 2 != 0:
	print(-1)
else:
	print(total // 2)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = Counter(a)
cb = Counter(b)

def solve():
	ans = 0
	balance = {}
	for mark in range(1, 6):
		c1 = ca.get(mark, 0)
		c2 = cb.get(mark, 0)
		s = c1 + c2
		if s % 2 != 0:
			return -1
		balance[mark] = c1 - s / 2
	if sum(balance.values()) != 0:
		return -1
	return int(sum(map(abs, balance.values())) / 2)
print(solve())


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
counterA = [0, 0, 0, 0, 0]
counterB = [0, 0, 0, 0, 0]
for i in range(n):
	counterA[a[i] - 1] += 1
for i in range(n):
	counterB[b[i] - 1] += 1
anyCountOdd = False
for i in range(5):
	if (counterA[i] + counterB[i]) % 2 == 1:
		anyCountOdd = True
		break
if anyCountOdd:
	print('-1')
else:
	exchanges = 0
	for i in range(5):
		midValue = (counterA[i] + counterB[i]) // 2
		if counterA[i] > counterB[i]:
			exchanges += counterA[i] - midValue
		else:
			exchanges += counterB[i] - midValue
	exchanges //= 2
	print(exchanges)


from collections import Counter
n = int(input())
a = Counter(list(map(int, input().split())))
b = Counter(list(map(int, input().split())))
possible = True
for i in range(1, 6):
	if (a[i] + b[i]) % 2:
		possible = False
		break
if not possible:
	print(-1)
else:
	ans = 0
	for i in range(1, 6):
		tot = (a[i] + b[i]) // 2
		if a[i] < tot:
			ans += tot - a[i]
	print(ans)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ex = 0
c = 0
for i in range(1, 6):
	a1 = a.count(i)
	b1 = b.count(i)
	x = a1 + b1
	if x % 2 != 0:
		c = 1
		break
	else:
		ex += x // 2 - min(a1, b1)
if c == 1:
	print(-1)
else:
	print(ex // 2)


from collections import Counter
n = int(input().strip())
ca = Counter([int(x) for x in input().strip().split(' ')])
cb = Counter([int(x) for x in input().strip().split(' ')])
cnt = 0
for i in range(1, 6):
	if (ca[i] + cb[i]) % 2 != 0:
		print(-1)
		exit(0)
	else:
		cnt += abs(ca[i] - (ca[i] + cb[i]) / 2)
print(int(cnt / 2))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
do = True
cnt = [0] * 5
ans = 0
for i in range(n):
	cnt[a[i] - 1] += 1
	cnt[b[i] - 1] -= 1
for i in range(5):
	if cnt[i] % 2 == 1:
		do = False
		break
if not do:
	print('-1')
else:
	for i in range(5):
		ans += abs(cnt[i])
	print(ans // 4)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	a = collections.Counter(LI())
	b = collections.Counter(LI())
	ks = set(a.keys()) | set(b.keys())
	r = 0
	for k in ks:
		s = abs(a[k] - b[k])
		if s % 2 == 1:
			return -1
		r += s
	return r // 4
print(main())


n = int(input())
(perfsA, perfsB) = ([0, 0, 0, 0, 0], [0, 0, 0, 0, 0])
(list1, list2) = (input().split(), input().split())
for num in list1:
	num = int(num)
	perfsA[num - 1] += 1
for num in list2:
	num = int(num)
	perfsB[num - 1] += 1
swips = 0
for i in range(0, 5):
	if abs(perfsA[i] - perfsB[i]) % 2 == 1:
		swips = -1
		break
	swips += abs(perfsB[i] - perfsA[i]) / 2
if swips % 2 == 1:
	print(-1)
else:
	print(int(swips / 2))


input()
a = [0 for i in range(6)]
b = [0 for i in range(6)]
for i in list(map(int, input().split())):
	a[i] += 1
for i in list(map(int, input().split())):
	b[i] += 1
ans = 0
for i in range(6):
	if (a[i] + b[i]) % 2 > 0:
		print('-1')
		exit(0)
	ans += abs(a[i] - (a[i] + b[i]) // 2)
print(ans // 2)


input()
fst = [int(x) for x in input().split()]
snd = [int(x) for x in input().split()]

def count(arr):
	res = {i: 0 for i in range(1, 6)}
	for i in arr:
		res[i] += 1
	return res

def solve():
	total = count(fst + snd)
	fst_ = count(fst)
	snd_ = count(snd)
	for v in total.values():
		if v % 2 != 0:
			return -1
	res = 0
	for (k, v) in fst_.items():
		diff = v - total[k] // 2
		res += diff if diff > 0 else 0
	return res
print(solve())


n = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
w = True
ans = 0
for i in range(1, 6):
	Sum = a.count(i) + b.count(i)
	if Sum % 2 == 1:
		w = False
	ans += abs(a.count(i) - b.count(i))
if ans == int(ans) and w:
	print(int(ans // 4))
else:
	print('-1')


n = int(input())
a = []
b = []
y = input()
x = y.split()
for i in range(n):
	a.append(int(x[i]))
y = input()
x = y.split()
for i in range(n):
	b.append(int(x[i]))
a1 = abs(a.count(1) - b.count(1))
a2 = abs(a.count(2) - b.count(2))
a3 = abs(a.count(3) - b.count(3))
a4 = abs(a.count(4) - b.count(4))
a5 = abs(a.count(5) - b.count(5))
j = [a1, a2, a3, a4, a5]
j.sort()
if a1 % 2 == 0 and a2 % 2 == 0 and (a3 % 2 == 0) and (a4 % 2 == 0) and (a5 % 2 == 0):
	if (j[4] + j[3] + j[2] + j[1] + j[0]) / 2 % 2 == 0:
		print(int((j[4] + j[3] + j[2] + j[1] + j[0]) / 4))
	else:
		print(-1)
else:
	print(-1)


a = int(input())
b_ = input().split()
c_ = input().split()

def f(a, b_, c_):
	d1 = dict()
	d2 = dict()
	d = dict()
	for i in b_:
		if i not in d1:
			d1[i] = 0
		if i not in d:
			d[i] = 0
		d1[i] += 1
		d[i] += 1
	for j in c_:
		if j not in d2:
			d2[j] = 0
		if j not in d:
			d[j] = 0
		d2[j] += 1
		d[j] += 1
	ans = 0
	for i in d:
		if d[i] % 2:
			return -1
		else:
			if i not in d2:
				d2[i] = 0
			if i not in d1:
				d1[i] = 0
			ans += abs((d1[i] + d2[i]) // 2 - d1[i])
	return ans // 2
print(f(a, b_, c_))


n = int(input())
a = input()
b = input()
w = 0
s = 0
p = 0
leva = []
levb = []
A = [int(s) for s in a.split()]
B = [int(s) for s in b.split()]
for k in range(5):
	leva.append(0)
	levb.append(0)
	for i in range(n):
		if A[i] == k + 1:
			leva[k] += 1
		if B[i] == k + 1:
			levb[k] += 1
for i in range(5):
	w += leva[i] - levb[i]
	s += abs(leva[i] - levb[i]) / 4
	if (leva[i] + levb[i]) % 2 != 0:
		p = -1
if w == 0 and s % 1 == 0 and (p == 0):
	print(int(s))
else:
	print(-1)


n = int(input())
g1 = list(map(int, input().split()))
g2 = list(map(int, input().split()))
(G1, G2) = ({x: g1.count(x) for x in range(1, 6)}, {x: g2.count(x) for x in range(1, 6)})

def solve():
	ans = 0
	for i in range(1, 6):
		curr = G1[i] + G2[i]
		if curr & 1:
			return '-1'
		else:
			ans += max(0, G1[i] - curr // 2)
	return ans
print(solve())


N = int(input())
As = list(map(int, input().split()))
Bs = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
	a = As.count(i)
	b = Bs.count(i)
	if abs(a - b) % 2 == 1:
		ans = -2
		break
	else:
		ans += abs(a - b) // 2
print(ans // 2)


n = int(input().strip())
cl1 = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
cl2 = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
x = list(map(int, input().strip().split(' ')))
for i in x:
	cl1[i] += 1
x = list(map(int, input().strip().split(' ')))
for i in x:
	cl2[i] += 1
d1 = 0
d2 = 0
flage = True
for i in range(1, 6):
	if cl1[i] > cl2[i]:
		t = cl1[i] - cl2[i]
		if t % 2 == 0:
			d1 += t / 2
		else:
			flage = False
			print(-1)
			break
	elif cl2[i] > cl1[i]:
		t = cl2[i] - cl1[i]
		if t % 2 == 0:
			d2 += t / 2
		else:
			flage = False
			print(-1)
			break
if flage:
	if d1 == d2:
		print(int(d1))
	else:
		print(-1)


z = lambda : {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
input()
b = z()
c = z()
s = s1 = n = 0
for (i, j) in zip(map(int, input().split()), map(int, input().split())):
	b[i] += 1
	c[j] += 1
for i in b:
	z1 = b[i] + c[i]
	if z1 & 1:
		exit(print(-1))
	if z1 // 2 - b[i] > 0:
		n += z1 // 2 - b[i]
	s += z1 // 2 - b[i]
	s1 += z1 // 2 - c[i]
print(n if s == s1 else -1)


import math
n = int(input())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
k = 0
s = 0
for i in range(1, 6):
	x = a.count(i)
	y = b.count(i)
	if (x + y) % 2 != 0:
		k = 1
		break
	else:
		s += abs(x - y)
if k == 1 or s % 4 != 0:
	print(-1)
else:
	print(s // 4)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ax = [0, 0, 0, 0, 0, 0]
bx = [0, 0, 0, 0, 0, 0]
for i in range(n):
	ax[a[i]] += 1
	bx[b[i]] += 1
ans = 0
for i in range(6):
	if (ax[i] + bx[i]) % 2 == 1:
		ans = -1
		break
	else:
		ans += abs((ax[i] - bx[i]) // 2)
print(ans // 2)


n = int(input())
G = {}
s = 0
for i in range(1, 6):
	G[i] = 0
for x in map(int, input().split()):
	G[x] += 1
for x in map(int, input().split()):
	G[x] -= 1
for i in range(1, 6):
	if G[i] % 2 == 1:
		print(-1)
		exit(0)
	s += abs(G[i])
print(s // 4)


n = int(input())
ta = list(map(int, input().split()))
tb = list(map(int, input().split()))
a = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
b = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for i in ta:
	a[i] = a.get(i, 0) + 1
for i in tb:
	b[i] = b.get(i, 0) + 1
it = 0
for key in a:
	k = a[key] - b[key]
	if k % 2 == 1:
		print(-1)
		exit()
	k //= 2
	it += abs(k)
if it % 2 == 1:
	print(-1)
else:
	print(it // 2)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
k = 0
for i in range(1, 6):
	in_A = A.count(i)
	in_B = B.count(i)
	if (in_A + in_B) % 2 != 0:
		print(-1)
		break
	else:
		k += abs(in_A - (in_A + in_B) // 2)
else:
	print(k // 2)


n = int(input())
a = [int(z) for z in input().split()]
b = [int(z) for z in input().split()]
(c1, d1, e1, f1, g1) = (0, 0, 0, 0, 0)
(c2, d2, e2, f2, g2) = (0, 0, 0, 0, 0)
for i in a:
	if i == 1:
		c1 += 1
	elif i == 2:
		d1 += 1
	elif i == 3:
		e1 += 1
	elif i == 4:
		f1 += 1
	else:
		g1 += 1
for i in b:
	if i == 1:
		c2 += 1
	elif i == 2:
		d2 += 1
	elif i == 3:
		e2 += 1
	elif i == 4:
		f2 += 1
	else:
		g2 += 1
if c1 + c2 & 1 or d1 + d2 & 1 or e1 + e2 & 1 or f1 + f2 & 1 or g1 + g2 & 1:
	print(-1)
else:
	print((abs((c1 + c2) // 2 - c1) + abs((d1 + d2) // 2 - d1) + abs((e1 + e2) // 2 - e1) + abs((f1 + f2) // 2 - f1) + abs((g1 + g2) // 2 - g1)) // 2)


from sys import stdin, stdout
class1 = []
class2 = []
data_length = int(stdin.readline())
c1 = map(int, stdin.readline().split())
c2 = map(int, stdin.readline().split())
c1d = {}
c2d = {}
for mark in c1:
	c1d[mark] = c1d.get(mark, 0) + 1
for mark in c2:
	c2d[mark] = c2d.get(mark, 0) + 1
perm = 0
for mark in range(1, 6):
	if (c1d.get(mark, 0) + c2d.get(mark, 0)) % 2 == 1:
		stdout.write('-1' + '\n')
		exit(0)
diff = 0
for mark in range(1, 6):
	diff += abs(c1d.get(mark, 0) - c2d.get(mark, 0))
stdout.write(str(diff // 4) + '\n')


n = int(input())
al = [int(x) for x in input().split()]
bl = [int(x) for x in input().split()]
a = {1: al.count(1), 2: al.count(2), 3: al.count(3), 4: al.count(4), 5: al.count(5)}
b = {1: bl.count(1), 2: bl.count(2), 3: bl.count(3), 4: bl.count(4), 5: bl.count(5)}
possible = True
for key in a.keys():
	if (a[key] + b[key]) % 2 != 0:
		possible = False
		break
if possible:
	swaps = 0
	for key in a.keys():
		if a[key] > b[key]:
			swaps += (a[key] - b[key]) // 2
	print(swaps)
else:
	print(-1)


a = int(input(''))
lista = list(map(int, input().split(' ')))
listb = list(map(int, input().split(' ')))
dif = [0]
for i in range(1, 6, 1):
	dif.append(lista.count(i) - listb.count(i))
count = sum(dif)
if count == 0:
	for i in range(1, 6, 1):
		dif[i] = abs(dif[i])
		if dif[i] % 2 != 0:
			print('-1')
			exit()
	print(int(sum(dif) / 4))
else:
	print('-1')


def Can():
	sum = 0
	for i in range(1, 6):
		if (mapa1[i] + mapa2[i]) % 2 == 1:
			return -1
		else:
			sum += abs((mapa1[i] + mapa2[i]) / 2 - mapa1[i])
	return int(sum / 2)
n = int(input())
l1 = l2 = []
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
mapa1 = {}
mapa2 = {}
for i in range(1, 6):
	mapa1[i] = 0
	mapa2[i] = 0
for i in range(0, n):
	mapa1[l1[i]] += 1
	mapa2[l2[i]] += 1
print(Can())


n = int(input())
A = list(map(int, input().split()))
a = [0] * 6
B = list(map(int, input().split()))
b = [0] * 6
for i in A:
	if i == 1:
		a[1] += 1
	if i == 2:
		a[2] += 1
	if i == 3:
		a[3] += 1
	if i == 4:
		a[4] += 1
	if i == 5:
		a[5] += 1
for i in B:
	if i == 1:
		b[1] += 1
	if i == 2:
		b[2] += 1
	if i == 3:
		b[3] += 1
	if i == 4:
		b[4] += 1
	if i == 5:
		b[5] += 1
ans = 0
f = True
for i in range(1, 6):
	if (a[i] + b[i]) % 2 == 1:
		f = False
if f:
	for i in range(1, 6):
		ans += abs(a[i] - (a[i] + b[i]) // 2)
if f:
	print(ans // 2)
else:
	print(-1)


n = int(input())
A = dict()
for i in range(1, 6):
	A[i] = 0
lA = list(map(int, input().split()))
for la in lA:
	A[la] += 1
B = dict()
for i in range(1, 6):
	B[i] = 0
lB = list(map(int, input().split()))
for lb in lB:
	B[lb] += 1
cnt = 0
for i in range(1, 6):
	a = abs(B[i] - A[i])
	if a % 2 == 0:
		cnt += a // 2
	else:
		print(-1)
		break
else:
	if cnt % 2 == 0:
		print(cnt // 2)
	else:
		print(-1)


n = int(input())
a = [0] * 5
a1 = [0] * 5
a2 = [0] * 5
f = 0
s1 = input().split()
s2 = input().split()
for i in range(n):
	s1[i] = int(s1[i])
	s2[i] = int(s2[i])
	a[s1[i] - 1] += 1
	a1[s1[i] - 1] += 1
	a[s2[i] - 1] += 1
	a2[s2[i] - 1] += 1
for i in range(5):
	if a[i] % 2 == 1:
		f = 1
if f == 1:
	print(-1)
else:
	k = 0
	sss = 0
	for i in range(5):
		k = a1[i] - a2[i]
		if k < 0:
			k = -1 * k
		k = k // 2
		sss += k
	print(sss // 2)


n = int(input())
(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
(ar, br, r) = ([0] * 5, [0] * 5, [0] * 5)
for x in a:
	ar[x - 1] += 1
	r[x - 1] += 1
for x in b:
	br[x - 1] += 1
	r[x - 1] += 1
if sum([x % 2 for x in r]) > 0:
	print(-1)
else:
	ans = 0
	for i in range(5):
		ans += abs(ar[i] - br[i]) // 2
	print(ans // 2)


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


c = 1
cases = 1
while c <= cases:
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ans = 0
	al = []
	bl = []
	for i in range(1, 6):
		if (a.count(i) + b.count(i)) % 2 == 0:
			if a.count(i) > b.count(i):
				al.append((a.count(i) - b.count(i)) // 2)
			elif a.count(i) < b.count(i):
				bl.append((b.count(i) - a.count(i)) // 2)
		else:
			ans = -1
			break
	if sum(al) == sum(bl) and ans != -1:
		ans = sum(al)
	print(ans)
	c = c + 1


from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
v = [0] * 6
for i in a:
	v[i] += 1
for i in b:
	v[i] -= 1
for i in v:
	if i % 2:
		print(-1)
		break
else:
	print(sum([abs(i) for i in v]) // 4)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
fa = [0] * 6
fb = [0] * 6
for i in a:
	fa[i] += 1
for i in b:
	fb[i] += 1
ans = 0
for i in range(6):
	xx = fa[i] + fb[i]
	if xx % 2 == 1:
		print(-1)
		exit()
	else:
		xx = xx // 2
		ans += min(abs(xx - fa[i]), abs(xx - fb[i]))
print(ans // 2)


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = list(map(int, input().split()))
b.sort()
d = [0, 0, 0, 0, 0, 0]
for i in a:
	d[i] += 1
for i in b:
	d[i] -= 1
if any((i & 1 for i in d)):
	print('-1')
else:
	ans = 0
	for i in range(1, 6):
		ans += abs(d[i])
	print(ans // 2 // 2)


import sys
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
n = I()
a = li()
b = li()
ans = 0
c = [0 for i in range(6)]
ac = [0 for i in range(6)]
for i in range(n):
	c[a[i]] += 1
	ac[a[i]] += 1
	c[b[i]] += 1
for i in range(6):
	if c[i] % 2 != 0:
		print(-1)
		exit()
	else:
		c[i] //= 2
for i in range(6):
	ans += max(0, ac[i] - c[i])
print(ans)


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
counts = [0, 0, 0, 0, 0, 0]
for i in range(n):
	counts[a[i]] += 1
	counts[b[i]] -= 1
can = True
for i in range(1, 6):
	if counts[i] % 2 != 0:
		can = False
		break
ans = -1
if can:
	ans = 0
	for i in range(1, 6):
		ans += abs(counts[i])
	ans //= 4
print(ans)


def abs(x):
	return x if x >= 0 else -x
a = [0] * 5
b = a[:]
n = int(input())
first = input().split()
second = input().split()
for i in first:
	a[int(i) - 1] += 1
for i in second:
	b[int(i) - 1] += 1
flag = False
sum = 0
for i in range(5):
	x = abs(a[i] - b[i])
	if x % 2 == 1:
		flag = True
		break
	sum += x // 2
if flag:
	print('-1')
else:
	print(sum // 2)


n = int(input())
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
ans = 0
count1 = [0, 0, 0, 0, 0, 0]
count2 = [0, 0, 0, 0, 0, 0]
flag = True
for i in range(1, 6):
	s = x1.count(i) + x2.count(i)
	count1[i] = x1.count(i)
	count2[i] = x2.count(i)
	if s % 2 == 1:
		flag = False
		break
if flag:
	x1.sort()
	x2.sort()
	for i in range(1, 6):
		for j in range(min(count1[i], count2[i])):
			x1.remove(i)
			x2.remove(i)
			count1[i] -= 1
			count2[i] -= 1
	l = len(x1)
	print(l // 2)
else:
	print(-1)


n = int(input())
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
count = [0] * 6
for i in range(1, 6):
	count[i] = a.count(i) - b.count(i)
ans = 0
for i in range(1, 6):
	for j in range(i + 1, 6):
		if count[i] * count[j] < 0:
			t = min(abs(count[i]), abs(count[j])) // 2
			ans += t
			count[i] += t * 2 if count[i] < 0 else -t * 2
			count[j] += t * 2 if count[j] < 0 else -t * 2
if count.count(0) == 6:
	print(ans)
else:
	print(-1)


from collections import Counter
n = int(input())
class_a = [int(x) for x in input().split()]
class_b = [int(x) for x in input().split()]
A = Counter(class_a)
B = Counter(class_b)
delta = 0
for grade in range(1, 6):
	if (A[grade] + B[grade]) % 2 == 1:
		print(-1)
		exit()
	delta += abs(A[grade] - B[grade])
print(delta // 4)


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
d1 = [0] * 6
d2 = [0] * 6
for x in l1:
	d1[x] += 1
for x in l2:
	d2[x] += 1
ans = 0
for i in range(6):
	if (d1[i] + d2[i]) % 2:
		print(-1)
		break
	ans += abs(d1[i] - d2[i])
else:
	print(ans // 4)


n = int(input())
a = map(int, input().strip().split())
b = map(int, input().strip().split())
cnta = 6 * [0]
cntb = cnta.copy()
for (x, y) in zip(a, b):
	cnta[x] += 1
	cntb[y] += 1
ok = True
res = 0
for (x, y) in zip(cnta, cntb):
	res += abs(x - y)
	if abs(x + y) % 2 != 0:
		ok = False
		break
if ok:
	res //= 4
else:
	res = -1
print(res)


n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ma = [0] * 5
mb = [0] * 5
for (a, b) in zip(A, B):
	ma[a - 1] += 1
	mb[b - 1] += 1
ca = 0
cb = 0
for (a, b) in zip(ma, mb):
	if (a + b) % 2 != 0:
		print(-1)
		exit()
	if a - b > 0:
		ca += (a - b) // 2
	elif a - b < 0:
		cb += (b - a) // 2
if ca == cb:
	print(ca)
else:
	print(-1)


n = int(input())
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
w = 0
ac = [0 for i in range(0, 6)]
bc = [0 for i in range(0, 6)]
for i in range(1, 6):
	ac[i] = a.count(i)
	bc[i] = b.count(i)
	if (ac[i] + bc[i]) % 2 != 0:
		w = 1
if w == 1:
	print(-1)
else:
	s1 = 0
	s2 = 0
	for i in range(1, 6):
		q = b.count(i) - (ac[i] + bc[i]) // 2
		if q > 0:
			s1 += q
		else:
			s2 += q
	if s1 == -s2:
		print(abs(s1))
	else:
		print(-1)


n = input()
a = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
b = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
tmp = input().split(' ')
for i in tmp:
	a[int(i)] += 1
tmp = input().split(' ')
for i in tmp:
	b[int(i)] += 1
coba = 0
for i in range(1, 5 + 1):
	tmp = a[i] + b[i]
	if tmp % 2 != 0:
		coba = 1
	tmp = min(a[i], b[i])
	a[i] -= tmp
	b[i] -= tmp
if coba == 1:
	print('-1')
else:
	ans = 0
	for i in range(1, 5 + 1):
		ans += a[i] // 2
	for i in range(1, 5 + 1):
		ans += b[i] // 2
	ans = ans // 2
	print(ans)


def func():
	n = int(input())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	A = [0] * 6
	B = [0] * 6
	for l in x:
		A[l] += 1
	for l in y:
		B[l] += 1
	res = 0
	for i in range(1, 6):
		if (A[i] - B[i]) % 2 != 0:
			return '-1'
		elif A[i] > B[i]:
			res += (A[i] - B[i]) / 2
	return int(res)
print(func())


f = int(input())
a = input()
a = [int(i) for i in a.split()]
b = input()
b = [int(i) for i in b.split()]
c = [0, 0, 0, 0, 0, 0]
cp = [0, 0, 0, 0, 0, 0]
ans = []
for i in a:
	c[i] += 1
for i in b:
	cp[i] += 1
t = 1
for i in range(len(c)):
	if (cp[i] + c[i]) % 2 == 1:
		print(-1)
		t = 0
		break
	else:
		ans.append(c[i] - (cp[i] + c[i]) // 2)
if t == 1:
	(pos, neg, su) = (0, 0, 0)
	for i in range(len(ans)):
		if ans[i] > 0:
			pos += ans[i]
		if ans[i] < 0:
			neg += ans[i]
		su += ans[i]
	if su < 0:
		print(-neg)
	if su == 0:
		print(pos)
	if su > 0:
		print(pos)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
total = [0] * 6
ac = [0] * 6
for val in a:
	ac[val] += 1
	total[val] += 1
bc = [0] * 6
for val in b:
	bc[val] += 1
	total[val] += 1
possible = True
for i in range(len(total)):
	if total[i] % 2 != 0:
		possible = False
		break
if not possible:
	print(-1)
else:
	out = 0
	for i in range(len(ac)):
		out += abs(total[i] / 2 - ac[i]) / 2
	print(int(out))


def f(a, b):
	n = 6
	d = [0] * n
	for i in range(len(a)):
		d[a[i]] += 1
		d[b[i]] -= 1
	if sum([d[i] % 2 > 0 for i in range(n)]) > 0:
		return -1
	return sum([d[i] >> 1 for i in range(n) if d[i] > 0])
_ = input()
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(f(a, b))


def ri():
	return map(int, input().split())
n = int(input())
a = list(ri())
b = list(ri())
ad = dict()
bd = dict()
for i in range(n):
	if not a[i] in ad:
		ad[a[i]] = 1
	else:
		ad[a[i]] += 1
	if not b[i] in bd:
		bd[b[i]] = 1
	else:
		bd[b[i]] += 1
ans = 0
for i in range(1, 6):
	ta = 0
	tb = 0
	if i in ad:
		ta += ad[i]
	if i in bd:
		tb += bd[i]
	if (ta + tb) % 2:
		print(-1)
		exit()
	else:
		ans += abs(ta - (ta + tb) // 2)
print(ans // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mas = [0] * 5
for i in range(n):
	mas[b[i] - 1] += 1
	mas[a[i] - 1] -= 1
answer = 0
for i in range(5):
	if mas[i] % 2 == 1:
		print(-1)
		break
	else:
		k = abs(mas[i])
		answer += k // 2
else:
	print(answer // 2)


n = int(input())
g1 = list(map(int, input().split()))
g2 = list(map(int, input().split()))
grade1 = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
grade2 = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
grades = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for i in g1:
	grades[i] += 1
	grade1[i] += 1
for i in g2:
	grades[i] += 1
	grade2[i] += 1
exch = 0
flag = 0
for i in range(1, 6):
	if grades[i] % 2:
		flag = -1
	if grade1[i] > grades[i] // 2:
		exch = exch + (grade1[i] - grades[i] // 2)
if flag == -1:
	print(flag)
else:
	print(exch)


from collections import defaultdict

def main():
	n = int(input())
	a = defaultdict(int)
	b = defaultdict(int)
	for x in map(int, input().split()):
		a[x] += 1
	for x in map(int, input().split()):
		b[x] += 1
	t1 = 0
	t2 = 0
	for x in range(1, 6):
		d = a[x] - b[x]
		if d % 2 == 1:
			print(-1)
			return
		d //= 2
		if d > 0:
			t1 += d
		elif d < 0:
			t2 -= d
	if t1 == t2:
		print(t1)
	else:
		print(-1)
main()


from collections import defaultdict
n = int(input())
aa = map(int, input().split())
bb = map(int, input().split())
q = defaultdict(int)
w = defaultdict(int)
e = defaultdict(int)
for a in aa:
	q[a] += 1
	e[a] += 1
for b in bb:
	w[b] += 1
	e[b] += 1
ans = 0
for i in range(1, 6):
	if e[i] % 2 != 0:
		ans = -1
		break
	ans += abs(q[i] - e[i] // 2)
print(ans // 2)


input()
(MyDict, All, Diff) = ({1: 0, 2: 0, 3: 0, 4: 0, 5: 0}, {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}, 0)
for i in list(map(int, input().split())):
	MyDict[i] += 1
	All[i] += 1
for i in list(map(int, input().split())):
	All[i] += 1
for key in All.keys():
	if All[key] % 2 == 1:
		print(-1)
		exit()
	Diff += abs(All[key] // 2 - MyDict[key])
print(Diff // 2)


n = int(input())
import sys
t = list(map(int, input().split()))
p = list(map(int, input().split()))
t1 = [0, 0, 0, 0, 0]
p1 = [0, 0, 0, 0, 0]
for i in range(n):
	if t[i] == 1:
		t1[0] += 1
	elif t[i] == 2:
		t1[1] += 1
	elif t[i] == 3:
		t1[2] += 1
	elif t[i] == 4:
		t1[3] += 1
	elif t[i] == 5:
		t1[4] += 1
	if p[i] == 1:
		p1[0] += 1
	elif p[i] == 2:
		p1[1] += 1
	elif p[i] == 3:
		p1[2] += 1
	elif p[i] == 4:
		p1[3] += 1
	elif p[i] == 5:
		p1[4] += 1
s = 0
for i in range(5):
	if abs(t1[i] - p1[i]) % 2 != 0:
		print(-1)
		sys.exit()
	s += abs(t1[i] - p1[i]) // 2
print(s // 2)


def isEven(number):
	if number % 2 == 0:
		return True
	else:
		return False
studentCount = int(input())
gradesA = [int(x) for x in input().split(' ')]
gradesB = [int(x) for x in input().split(' ')]
gradeCountA = [0, 0, 0, 0, 0, 0]
gradeCountB = [0, 0, 0, 0, 0, 0]
for x in gradesA:
	gradeCountA[x] += 1
for x in gradesB:
	gradeCountB[x] += 1
for x in range(1, 6):
	if not isEven(gradeCountB[x] + gradeCountA[x]):
		print('-1')
		exit()
desiredGradeCount = [0, 0, 0, 0, 0, 0]
for x in range(1, 6):
	desiredGradeCount[x] = (gradeCountB[x] + gradeCountA[x]) / 2
change = 0
for x in range(1, 6):
	change += abs(desiredGradeCount[x] - gradeCountA[x])
print(str(int(change // 2)))


n = int(input().strip())
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
a_d = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
b_d = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for i in range(n):
	a_d[a[i]] += 1
for i in range(n):
	b_d[b[i]] += 1
cnt = 0
for i in range(1, 6):
	if (a_d[i] + b_d[i]) % 2:
		print(-1)
		break
	else:
		cnt += abs(a_d[i] - b_d[i]) // 2
else:
	print(cnt // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aCnt = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
bCnt = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for i in range(n):
	aCnt[a[i]] += 1
	bCnt[b[i]] += 1
out = 0
for i in range(1, 6):
	if abs(aCnt[i] - bCnt[i]) % 2 == 1:
		print('-1')
		exit()
	out += abs(aCnt[i] - bCnt[i]) // 2
print(out // 2)


n = int(input())
a1 = list(map(int, input().split(' ')))
b1 = list(map(int, input().split(' ')))
a = [0] * 6
b = [0] * 6
for i in range(n):
	a[a1[i]] += 1
	b[b1[i]] += 1
res = 0
qqq = 1
for i in range(6):
	if abs(a[i] - b[i]) % 2 != 0:
		print('-1')
		qqq = -1
		break
	res += abs(a[i] - b[i]) / 2
if qqq == 1:
	print(int(res / 2))


n = int(input())
a = [int(i) for i in input().strip().split(' ')]
b = [int(i) for i in input().strip().split(' ')]
assert len(a) == len(b) == n
A = [0] * 5
B = [0] * 5
for i in range(n):
	A[a[i] - 1] = A[a[i] - 1] + 1
	B[b[i] - 1] = B[b[i] - 1] + 1
atob = 0
btoa = 0
badInput = False
for i in range(5):
	if (A[i] + B[i]) % 2 != 0:
		badInput = True
		break
	if A[i] >= B[i]:
		atob = atob + (A[i] - B[i]) // 2
	else:
		btoa = btoa + (B[i] - A[i]) // 2
if badInput:
	print(-1)
else:
	assert btoa == atob
	print(atob)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
for i in b:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
val = list(d.values())
somme = []
x = True
for i in val:
	if i % 2 != 0:
		x = False
		break
s = 0
neg = 0
pos = 0
if x:
	if len(val) == 1:
		print(0)
	else:
		for i in list(set(a)):
			if a.count(i) - d[i] // 2 < 0:
				neg += a.count(i) - d[i] // 2
			else:
				pos += a.count(i) - d[i] // 2
		s = min(abs(neg), pos) + abs(abs(neg) - pos)
		print(s)
else:
	print(-1)


n = int(input())
Sum = 0
classA = list(map(int, input().split()))
classB = list(map(int, input().split()))
w = False
for i in range(1, 6):
	if (classA.count(i) + classB.count(i)) % 2 == 1:
		w = True
		break
	else:
		Sum += abs(classA.count(i) - classB.count(i))
if w:
	print(-1)
else:
	print(int(Sum / 4))


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
numa = [0] * 5
numb = [0] * 5
for i in a:
	numa[i - 1] += 1
for i in b:
	numb[i - 1] += 1
failed = False
for i in range(0, 5):
	if (numa[i] + numb[i]) % 2 == 1:
		failed = True
		break
steps = 0
if failed:
	print(-1)
else:
	for i in range(0, 5):
		steps += abs(numa[i] - numb[i]) / 2
	print(int(steps / 2))


n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
A_grades = [0, 0, 0, 0, 0]
B_grades = [0, 0, 0, 0, 0]
for i in range(0, n):
	A_grades[A[i] - 1] += 1
	B_grades[B[i] - 1] += 1
l = 0
for i in range(0, 5):
	if (A_grades[i] + B_grades[i]) % 2 != 0:
		print(-1)
		l = 1
		break
dif = 0
for i in range(0, 5):
	dif += abs(A_grades[i] - B_grades[i])
if l == 0:
	print(dif // 4)


from collections import defaultdict
n = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
dictA = defaultdict(lambda : 0)
dictB = defaultdict(lambda : 0)
for x in A:
	dictA[x] += 1
for x in B:
	dictB[x] += 1
flag = True
for i in range(1, 6):
	if (dictA[i] + dictB[i]) % 2 is not 0:
		flag = False
		break
if not flag:
	print(-1)
else:
	count = 0
	for i in range(1, 6):
		if dictA[i] != dictB[i]:
			mid = (dictA[i] + dictB[i]) // 2
			count += mid - min(dictA[i], dictB[i])
	print(count // 2)


N = int(input())
L = list(map(int, input().split()))
R = list(map(int, input().split()))
L_cnt = {}
for i in range(1, 6):
	L_cnt[i] = L.count(i)
R_cnt = {}
for i in range(1, 6):
	R_cnt[i] = R.count(i)
sum_cnt = {}
for i in range(1, 6):
	sum_cnt[i] = L_cnt[i] + R_cnt[i]
	if sum_cnt[i] % 2 != 0:
		print('-1')
		exit()
ans = 0
for i in range(1, 6):
	if L_cnt[i] >= sum_cnt[i] // 2:
		ans += L_cnt[i] - sum_cnt[i] // 2
print(ans)


from collections import Counter
bad = False
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
counts_a = Counter(A)
counts_b = Counter(B)
counts_total = Counter(A + B)
swaps = 0
for i in range(1, 6):
	if counts_total[i] % 2 != 0:
		bad = True
	swaps += max(counts_a[i], counts_b[i]) - counts_total[i] // 2
if bad:
	print(-1)
else:
	print(swaps // 2)


import sys
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
	f = a.count(i)
	s = b.count(i)
	if (f + s) % 2 != 0:
		print(-1)
		sys.exit(0)
	ans += abs(f - s) // 2
print(ans // 2)


from sys import stdin
from collections import defaultdict
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
a_d = defaultdict(int)
b_d = defaultdict(int)
for i in range(n):
	a_d[a[i]] += 1
	b_d[b[i]] += 1
f = True
ans = 0
for i in range(6):
	if (a_d[i] + b_d[i]) % 2:
		f = False
		break
	ans += abs(a_d[i] - b_d[i])
if f:
	print(ans // 4)
else:
	print(-1)


from sys import stdin, stdout
n = int(stdin.readline())
first = list(map(int, stdin.readline().split()))
second = list(map(int, stdin.readline().split()))
cntf = [0, 0, 0, 0, 0]
cnts = [0, 0, 0, 0, 0]
for i in range(n):
	cntf[first[i] - 1] += 1
	cnts[second[i] - 1] += 1
label = 1
for i in range(5):
	if (cntf[i] + cnts[i]) % 2:
		label = 0
if not label:
	stdout.write('-1')
else:
	ans = 0
	for i in range(5):
		m = (cntf[i] + cnts[i]) // 2
		ans += max(cntf[i] - m, 0)
	stdout.write(str(ans))


a = input()
b = input()
c = input()
_b = {}
_c = {}
b = [int(x) for x in b.split()]
c = [int(x) for x in c.split()]
for i in range(1, 6):
	_b[str(i)] = 0
	_c[str(i)] = 0
for index in b:
	if str(index) in _b:
		_b[str(index)] += 1
	else:
		_b[str(index)] = 1
for index in c:
	if str(index) in _c:
		_c[str(index)] += 1
	else:
		_c[str(index)] = 1
number_of_changes = 0
stopped = False
for i in range(1, 6):
	if _b[str(i)] == _c[str(i)]:
		continue
	if (_b[str(i)] + _c[str(i)]) % 2 != 0:
		stopped = True
		print(-1)
		break
	number_of_changes += abs(_b[str(i)] - _c[str(i)]) / 2
if not stopped:
	print(int(number_of_changes / 2))


n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [0] * 6
d = [0] * 6
for i in range(n):
	c[a[i]] += 1
	d[b[i]] += 1

def compute():
	for i in range(1, 6):
		if (c[i] + d[i]) % 2 != 0:
			return -1
	x = 0
	y = 0
	for i in range(1, 6):
		if c[i] > d[i]:
			x += c[i] - d[i]
		elif d[i] > c[i]:
			y += d[i] - c[i]
	if x != y:
		return -1
	else:
		return x // 2
print(compute())


def f():
	n = int(input())
	i1 = input().strip().split()
	i2 = input().strip().split()
	a1 = [int(x) for x in i1]
	a2 = [int(x) for x in i2]
	b1 = [0, 0, 0, 0, 0]
	b2 = [0, 0, 0, 0, 0]
	d = [0, 0, 0, 0, 0]
	for i in a1:
		b1[i - 1] += 1
	for i in a2:
		b2[i - 1] += 1
	(sum, sum2) = (0, 0)
	for i in range(5):
		d[i] = b1[i] - b2[i]
		if d[i] % 2 != 0:
			print(-1)
			return
		sum += d[i]
		sum2 += abs(d[i])
	if sum != 0:
		print(-1)
	else:
		print(sum2 // 4)
f()


import sys

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def solve():
	n = int(input())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	cntA = [0] * 5
	cntB = [0] * 5
	for a in A:
		cntA[a - 1] += 1
	for b in B:
		cntB[b - 1] += 1
	ans = 0
	for k in range(5):
		if abs(cntA[k] - cntB[k]) % 2:
			print(-1)
			return None
		else:
			ans += abs(cntA[k] - cntB[k])
	ans //= 4
	print(ans)
solve()


def solve(l):
	for i in range(5):
		if abs(l[i] & 1):
			return -1
	ans = 0
	for i in range(5):
		if l[i] > 0:
			ans += l[i] // 2
	return ans
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
l = [0] * 5
for i in a:
	l[i - 1] += 1
for i in b:
	l[i - 1] -= 1
print(solve(l))


n = int(input())
ara1 = list(map(int, input().split()))
ara2 = list(map(int, input().split()))
count1 = [0] * 6
count2 = [0] * 6
sum = 0
flag = 0
for a in ara1:
	count1[a] += 1
for a in ara2:
	count2[a] += 1
for i in range(6):
	if (count1[i] - count2[i]) % 2 == 1:
		print(-1)
		flag = 1
		break
	else:
		sum += abs(count1[i] - count2[i])
if flag == 0:
	print(sum // 4)


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ''.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def nconv(number, base=3):
	newnumber = ''
	while number > 0:
		newnumber = str(number % base) + newnumber
		number //= base
	return newnumber
n = ii()
a = li()
b = li()
for i in range(5):
	if (a.count(i + 1) + b.count(i + 1)) % 2 != 0:
		print(-1)
		exit()
ans = 0
for i in range(5):
	ans += abs(a.count(i + 1) - b.count(i + 1)) // 2
print(ans // 2)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
a = L()
b = L()
da = defaultdict(int)
db = defaultdict(int)
for i in a:
	da[i] += 1
for j in b:
	db[j] += 1
s = list(set(list(da.keys()) + list(db.keys())))
for i in s:
	if (da[i] + db[i]) % 2 == 1:
		print(-1)
		exit()
ans = 0
for i in set(a):
	if da[i] > (da[i] + db[i]) // 2:
		p = (da[i] + db[i]) // 2
		ans += abs(p - da[i])
for i in set(b):
	if db[i] > (da[i] + db[i]) // 2:
		p = (da[i] + db[i]) // 2
		ans += abs(p - db[i])
print(ans // 2)


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(1, 6):
	if A.count(i) + B.count(i) & 1:
		exit(print('-1'))
	ans += abs(A.count(i) - B.count(i)) // 2
print(ans // 2)


n = int(input())
AScores = list(map(int, input().split()))
BScores = list(map(int, input().split()))
uniques = list()
for score in AScores:
	if score not in uniques:
		uniques.append(score)
for score in BScores:
	if score not in uniques:
		uniques.append(score)
switches = 0
for score in uniques:
	ACount = AScores.count(score)
	BCount = BScores.count(score)
	if (ACount + BCount) % 2 == 1:
		switches = -4
		break
	switches += abs(ACount - BCount)
print(int(switches / 4))


s = int(input())
a = input()
b = input()
changes = 0
for x in range(1, 6):
	a_c = a.count(str(x))
	b_c = b.count(str(x))
	if a_c % 2 != b_c % 2:
		print(-1)
		break
	changes += abs(a_c - b_c) // 2
else:
	print(changes // 2)


nb_pupil = int(input())
grp_1 = [int(x) for x in input().split()]
grp_2 = [int(x) for x in input().split()]
changed = 0
ans = -1
for i in range(1, 6):
	grp1 = grp_1.count(i)
	grp2 = grp_2.count(i)
	if not (grp1 + grp2) % 2:
		changed += abs(grp1 - grp2) // 2
		ans = 0
	else:
		ans = -1
		break
if ans != -1:
	print(changed // 2)
else:
	print(-1)


def calc():
	sum = 0
	for i in range(1, 6):
		a1 = a.count(i)
		a2 = b.count(i)
		if (a1 + a2) % 2 == 1:
			return -1
		sum += abs(a1 - a2)
	return sum // 4
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
print(calc())


def Pupils_redistribution():
	n = int(input())
	g1 = input().split()
	g1d = [0] * 5
	g2 = input().split()
	g2d = [0] * 5
	for i in g1:
		g1d[int(i) - 1] += 1
	for i in g2:
		g2d[int(i) - 1] += 1
	nd = [0] * 5
	for i in range(len(g1d)):
		a = g1d[i] - g2d[i]
		if a % 2 == 0:
			nd[i] = a / 2
		else:
			print('-1')
			break
	else:
		if sum(nd) == 0:
			sums = 0
			for i in nd:
				if i > 0:
					sums += i
			print(int(sums))
		else:
			print('-1')
Pupils_redistribution()


from sys import maxsize, stdout, stdin, stderr
tup = lambda : map(int, stdin.readline().split())
I = lambda : int(stdin.readline())
lint = lambda : [int(x) for x in stdin.readline().split()]
S = lambda : stdin.readline().replace('\n', '').strip()

def debug(*args, c=6):
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=stderr)
stpr = lambda x: stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
from collections import defaultdict
from collections import Counter
n = I()
a = lint()
b = lint()
cnt = [0] * 6
for i in range(n):
	cnt[a[i]] += 1
	cnt[b[i]] -= 1
s = 0
for i in cnt:
	if i % 2 != 0:
		stpr(-1)
		exit()
	elif i > 0:
		s += i
stpr(s // 2)


n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
al = [0] * 5
al1 = [0] * 5
al2 = [0] * 5
for i in l1:
	al[i - 1] += 1
	al1[i - 1] += 1
for i in l2:
	al[i - 1] += 1
	al2[i - 1] += 1
for i in al:
	if i % 2 == 1:
		print(-1)
		exit()
ans = 0
for i in range(5):
	ans += abs(al1[i] - al2[i])
print(ans // 4)


import sys

def input():
	return sys.stdin.readline()
n = int(input())
class_A = sorted(list(map(int, input().split())))
class_B = sorted(list(map(int, input().split())))
counts = [0] * 6
total = 0
for i in range(1, 6):
	counts[i] = class_A.count(i) + class_B.count(i)
	if counts[i] % 2:
		print(-1)
		sys.exit(0)
	counts[i] //= 2
for i in range(1, 6):
	total += abs(counts[i] - class_A.count(i))
print(total // 2)


c = 0
a = int(input())
(x, l) = [list(map(int, input().split())) for i in range(2)]
x.sort()
l.sort()
for i in range(1, 6):
	k = abs(x.count(i) - l.count(i))
	if k % 2 == 1:
		a = 0
		break
	else:
		c += k
print(c // 4 if c % 4 == 0 and a != 0 else -1)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0, 0, 0, 0, 0]
for i in a:
	c[i - 1] += 1
for j in b:
	c[j - 1] -= 1
c = [abs(i) for i in c]
import sys
for i in c:
	if i % 2:
		print(-1)
		sys.exit(0)
print(sum(c) // 4)


n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
count = 0
a_dict = [a.count(1), a.count(2), a.count(3), a.count(4), a.count(5)]
b_dict = [b.count(1), b.count(2), b.count(3), b.count(4), b.count(5)]
possible = False
for i in range(5):
	numbers_count = a_dict[i] + b_dict[i]
	if numbers_count % 2 == 1:
		possible = False
		break
	else:
		possible = True
if a_dict[0] > b_dict[0]:
	count += (a_dict[0] - b_dict[0]) // 2
if a_dict[1] > b_dict[1]:
	count += (a_dict[1] - b_dict[1]) // 2
if a_dict[2] > b_dict[2]:
	count += (a_dict[2] - b_dict[2]) // 2
if a_dict[3] > b_dict[3]:
	count += (a_dict[3] - b_dict[3]) // 2
if a_dict[4] > b_dict[4]:
	count += (a_dict[4] - b_dict[4]) // 2
if possible:
	print(count)
else:
	print('-1')


import collections
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(c, l) = (0, [])
for i in range(1, 6):
	k = a.count(i) - b.count(i)
	if k % 2 == 0:
		l.append(k // 2)
	else:
		c = 1
		break
ans = 0
if c == 1:
	print('-1')
elif sum(l) != 0:
	print(-1)
else:
	for i in l:
		if i > 0:
			ans += i
	print(ans)


n = int(input())
R = lambda : list(map(int, input().split()))
(a1, a2) = (R(), R())
from collections import Counter
(c1, c2) = (Counter(a1), Counter(a2))
ans = 0
for i in range(1, 6):
	(v1, v2) = (c1.get(i, 0), c2.get(i, 0))
	if (v1 + v2) % 2 != 0:
		print(-1)
		exit()
	ans += abs((v1 + v2) // 2 - v1)
if ans % 2 == 0:
	print(ans // 2)
else:
	print(-1)


import sys

def make_splits(group_a, group_b):
	r = group_a.copy()
	r = group_a + group_b
	ratings = sorted(r)
	target_a = []
	target_b = []
	for i in range(0, len(ratings), 2):
		if ratings[i] != ratings[i + 1]:
			print(-1)
			sys.exit(0)
		target_a.append(ratings[i])
		target_b.append(ratings[i + 1])
	return (target_a, target_a)

def find_lcs_dp(target_a, target_b, m, n):
	cache = [[None] * (n + 1) for i in range(m + 1)]
	for i in range(m + 1):
		for j in range(n + 1):
			if i == 0 or j == 0:
				cache[i][j] = 0
			elif target_a[i - 1] == target_b[j - 1]:
				cache[i][j] = cache[i - 1][j - 1] + 1
			else:
				cache[i][j] = max(cache[i - 1][j], cache[i][j - 1])
	return cache[m][j]
ns = int(input().strip())
group_a = [int(i) for i in str(input()).split()]
group_b = [int(i) for i in str(input()).split()]
(target_a, target_b) = make_splits(group_a, group_b)
m = find_lcs_dp(sorted(group_a), target_a, len(target_a), len(target_b))
print(ns - m)


from collections import Counter
(n, v, c1, c2) = (int(input()), 0, Counter(map(int, input().split())), Counter(map(int, input().split())))
for i in range(1, 6):
	x = c1[i] + c2[i]
	if (c1[i] + c2[i]) % 2:
		print(-1)
		exit()
	else:
		v += abs(c1[i] - c2[i]) // 2
print(v // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
x = [0 for _ in range(6)]
res = 0
flag = False
for i in range(n):
	x[a[i]] += 1
	x[b[i]] -= 1
for c in x:
	if c % 2:
		print(-1)
		flag = True
		break
	res += abs(c) // 2
if not flag:
	print(res // 2)


import sys
import math
import bisect

def transform(A):
	B = [0] * 5
	for i in range(len(A)):
		B[A[i] - 1] += 1
	return B

def solve(A, B):
	n = len(A)
	A = transform(A)
	B = transform(B)
	for i in range(5):
		min_val = min(A[i], B[i])
		A[i] -= min_val
		B[i] -= min_val
	ans = 0
	for i in range(5):
		tmp = A[i] + B[i]
		if tmp % 2 == 1:
			return -1
		ans += tmp
	return ans // 4

def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = solve(A, B)
	print(ans)
main()


n = int(input())
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
count = [0] * 5
for grade in a:
	count[grade - 1] += 1
for grade in b:
	count[grade - 1] -= 1
suma = 0
flag = True
for item in count:
	if item % 2 == 1:
		flag = False
		break
	else:
		suma += abs(item) // 2
if flag:
	print(suma // 2)
else:
	print(-1)


n = int(input())
cnt = [0] * 5
A = [int(i) - 1 for i in input().split()]
B = [int(i) - 1 for i in input().split()]
for i in A:
	cnt[i] += 1
for i in B:
	cnt[i] -= 1
res_4 = sum((abs(i) for i in cnt))
for i in cnt:
	if i % 2 == 1:
		print(-1)
		exit()
if res_4 % 4 != 0:
	print(-1)
else:
	print(res_4 // 4)


import sys

def make_gen(str):
	arr = str.split(' ')
	for item in arr:
		yield int(item)
n = int(input())
class_a = [0] * 5
class_b = [0] * 5
s = input()
s = make_gen(s)
for i in range(0, n):
	x = next(s)
	class_a[x - 1] += 1
s = input()
s = make_gen(s)
for i in range(0, n):
	x = next(s)
	class_b[x - 1] += 1
change1 = 0
change2 = 0
for i in range(0, 5):
	if (class_a[i] + class_b[i]) % 2 == 1:
		print(-1)
		sys.exit()
	med = (class_a[i] + class_b[i]) // 2
	change1 += abs(class_a[i] - med)
	change2 += abs(class_a[i] - med)
if change1 == change2:
	print(change1 // 2)
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ca = [0, 0, 0, 0, 0]
cb = [0, 0, 0, 0, 0]
for i in a:
	ca[i - 1] += 1
for i in b:
	cb[i - 1] += 1
c = 0
for i in range(5):
	if (ca[i] + cb[i]) % 2 == 0:
		c += (max(ca[i], cb[i]) - min(ca[i], cb[i])) // 2
	else:
		print(-1)
		return
print(c // 2)


n = int(input())
p = list(map(int, input().split()))
ka = list(map(int, input().split()))
so = list(set(p))
po = list(set(ka))
tod = []
lol = []
sam = []
lil = []
loll = 0
tt = []
lkl = []
for item in so:
	tod.append(item)
for item in po:
	if item not in tod:
		tod.append(item)
for item in tod:
	lol.append(ka.count(item) + p.count(item))
for item in lol:
	if item % 2 == 0:
		pass
	else:
		loll = 1
		break
if loll == 1:
	print(-1)
else:
	lol = []
	for item in tod:
		sam.append(p.count(item))
		lol.append(ka.count(item))
	for x in range(len(sam)):
		if sam[x] == lol[x]:
			pass
		elif sam[x] > lol[x]:
			tt.append((sam[x] + lol[x]) // 2 - lol[x])
		else:
			lkl.append((sam[x] + lol[x]) // 2 - sam[x])
	if sum(tt) != sum(lkl):
		print(-1)
	else:
		print(sum(tt))


def sol():
	total = 0
	for i in range(1, 6):
		count1 = 0
		count2 = 0
		for j in range(n):
			if l1[j] == i:
				count1 += 1
			if l2[j] == i:
				count2 += 1
		if (count2 + count1) % 2 == 0:
			total += abs(count2 - (count1 + count2) // 2)
		else:
			return -2
	return total
n = int(input())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
print(sol() // 2)


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = [0] * 6
for i in a:
	cnt[i] += 1
for i in b:
	cnt[i] -= 1
su = 0
for i in cnt:
	if i % 2 != 0:
		print(-1)
		exit()
	if i > 0:
		su += i
print(su // 2)


from sys import stdin
n = int(stdin.readline().rstrip())
diff = [0, 0, 0, 0, 0]
for x in stdin.readline().rstrip().split(' '):
	diff[int(x) - 1] += 1
for x in stdin.readline().rstrip().split(' '):
	diff[int(x) - 1] -= 1
result = 0
for k in diff:
	if k % 2 == 1:
		print(-1)
		exit()
	elif k > 0:
		result += k
print(result // 2)


n = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
ad = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
bd = {1: 0, 2: 0, 3: 0, 4: 0, 5: 0}
for a in al:
	ad[a] += 1
for b in bl:
	bd[b] += 1
flag = True
num = 0
for i in range(1, 6):
	cur = abs(ad[i] - bd[i])
	if abs(ad[i] - bd[i]) % 2 > 0:
		flag = False
		break
	num += cur
if flag:
	print(num // 4)
else:
	print(-1)


x = input()
s_1 = input()
s_2 = input()
s_1 = s_1.split(' ')
s_2 = s_2.split(' ')
first = []
second = []
i = 0
answer = 0
k = 0
for i in range(1, 6):
	first.append(0)
	second.append(0)
i = 0
for i in range(0, len(s_1)):
	first[int(s_1[i]) - 1] += 1
j = 0
for j in range(0, len(s_2)):
	second[int(s_2[j]) - 1] += 1
for i in range(0, 5):
	answer += max(first[i], second[i]) - (first[i] + second[i]) // 2
	if (first[i] + second[i]) % 2 != 0:
		print(-1)
		exit(0)
print(answer // 2)


n = int(input())
A = [0] * 5
B = [0] * 5
for a in map(int, input().split()):
	A[a - 1] += 1
for a in map(int, input().split()):
	B[a - 1] += 1
if any([(x + y) % 2 != 0 for (x, y) in zip(A, B)]):
	print(-1)
else:
	print(sum([abs(x - y) // 2 for (x, y) in zip(A, B)]) // 2)


n = int(input())
g1 = list(map(int, input().split()))
g2 = list(map(int, input().split()))
c1 = {i: 0 for i in range(1, 6)}
c2 = {i: 0 for i in range(1, 6)}
for i in range(n):
	c1[g1[i]] += 1
	c2[g2[i]] += 1
if all(((c1[i] - c2[i]) % 2 == 0 for i in range(1, 6))) and sum((c1[i] - c2[i] for i in range(1, 6))) == 0:
	print(sum((abs(c1[i] - c2[i]) for i in range(1, 6))) // 4)
else:
	print(-1)