import sys
man_nub, man_name, tou_nub, piao = map(str, sys.stdin.readlines())
man_name = [i.strip() for i in man_name.split(' ')]
piao = [i.strip() for i in piao.strip().split(' ')]
a = 0
for i in man_name:
n = piao.count(i)
print(f'{i} : {n}')
a = a + n
print(f'Invalid : ' + str(int(tou_nub) - a))