n = int(input())
candidate = input().split()
people = int(input())
votes = input().split()

cnt_votes = {}
for i in candidate:
    cnt_votes[i] = 0

useless = 0

for vote in votes:
    if vote in cnt_votes:
        cnt_votes[vote] +=1
    else:
        useless += 1

for i in candidate:
    print(f"{i} : {cnt_votes[i]}")

print(f"Invalid : {useless}")