It works for all test cases. But submission verdict is WA.
Can anyone help finding the mistake?
`from collections import Counter
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ac=Counter(a)
bc=Counter(b)
weird=(ac-bc)+(bc-ac)
temp=list(weird.values())
sumi=0
i=0
try:
while(i<len(temp)):
if(temp[i]%2==0):
sumi+=temp[i]
else:
raise Exception
i+=1
except Exception as e:
sumi=-1
if(sumi/4==sumi//4):
print(sumi//4)
else:
print(-1)`
Link to original solution: https://www.codechef.com/viewsolution/35520862