i1 = int(input())
lt1 = input().split( )
i2 = int(input())
lt2 = input().split( )

Invalid = 0

for k in lt2:
    if k not in lt1:
        Invalid=Invalid+1
for w in lt1:
    print(w+' : '+str(lt2.count(w)))
print('Invalid :',Invalid)