while True:
try:
n = int(input())
name_list = input().split()
m = int(input())
vote_list = input().split()
valid_count = 0
for i in name_list:
valid_count += vote_list.count(i)
print(i + ' : ' + str(vote_list.count(i)))
print('Invalid : ' + str(m - valid_count))
except:
break