while True:
    try:
        n, names, total, rotes = int(input()), input().split(), int(input()),input().split()
        dic = {k : 0 for k in names}
        dic['Invalid'] = 0
        for k in rotes:
            if k in dic:
                dic[k] += 1
            else:
                dic['Invalid'] += 1
        for k in dic:
            print(k, ':', dic[k])
    except:
        break