while True:
    try:
        num_candidate = int(input())
        candidate_list = input().split()
        num_vote = int(input())
        vote_list = input().split()
        total_count=0
        for candidate in candidate_list:
            count=vote_list.count(candidate)
            total_count = total_count+count
            print(candidate,':',str(count))

        print('Invalid',':',str(num_vote - total_count))
    except:
        break