import sys
mamber, name, pepple, votes = [line.replace("\n", "").split() for line in sys.stdin]  
a = 0
for i in name:
    answer = votes.count(i)
    print(i, ":", answer, sep=" ")
    a += answer
print("Invalid :", len(votes) - a)