while True:
    try:
        n = map(int, input())
        name_list = input().split()
        m = map(int, input())
        vote_name = input().split()
        # print(vote_name)
        vote_dict = {}
        for i in name_list:
            vote_dict[i] = vote_name.count(i)
        # print(vote_dict)
        Invalid_count = 0
        for j in vote_name:
            if j not in name_list:
                Invalid_count += 1
        vote_dict['Invalid'] = Invalid_count
        # print(vote_dict)
        for key, value in vote_dict.items():
            print(key, ':', value)
    except Exception as e:
        break