while True: try: num1 = int(input()) list1 = [] list3 = [] for i in range(num1): list1.append(input()) list3.append(0) num2 = int(input()) list2 = [] count = 0 flag = 0 for i in range(num2): list2.append(input()) for i in range(num2): for j in range(num1): if list1[j] == list2[i]: list3[j] = 1 if list1[j] == list2[i] and sum(list3)==len(list3): flag = 1 count += 1 for k in range(num1): if k == j: continue list3[k] = 0 if flag == 0 or num1 == 1: print(-1) continue print(count) except EOFError: break