# 20241008
n = int(input())         #候选人
ls = input().split()     #候选人的名字
m = int(input())         #投票的人数
ls1 = input().split()    #投票
c = 0

for i in ls:
    c += ls1.count(i)
    print(i+' : '+str(ls1.count(i)))
print("Invalid : " + str(m-c))