n = int(input())
hx = input().split()
tol_num = int(input())
tp = input().split()
inval = 0
dp = []
for i in hx:
x = 0
for j in tp:
if i == j:
x += 1
dp.append(x)
yx = 0
for i in dp:
yx += i
for i in range(0, len(hx)):
print(hx[i] +' : '+ str(dp[i]))
print('Invalid : ' + str(tol_num - yx))