while True:
    try:
        candidates = int(input())
        cand_name = input().split()
        voters = int(input())
        votes = input().split()        
        for i in cand_name:
            print(i, ":", votes.count(i))
        count = 0
        for i in votes:
            if i not in cand_name:
                count += 1
        print("Invalid",":", count)
    except:
        break