while True:
try:
n = int(input())
candidates = input().split()
m = int(input())
votes = input().split()
invalid = 0
counts = [0] * len(candidates)
for i in range(m):
if votes[i] in candidates:
counts[candidates.index(votes[i])] += 1
else:
invalid += 1
for i in range(n):
print(f"{candidates[i]} : {counts[i]}")
print(f"Invalid : {invalid}")
except:
break