"""
其实就是统计指定文件的指定行号的数量,例如如果输入是
E:\V1R2\product\fpgadrive.c   1325
E:\V1R2\product\fpgadrive.c   1325
E:\V1R2\product\fpgadrive.c   1325
则输出是
fpgadrive.c 1325 3

"""
dic = dict()
name_lines = []

while True:
    try:
        lst = list(input().split())
        name = lst[0].split('\\')[-1][-16:]
        name_line = name + ' ' + lst[1]
        if name_line not in dic:
            dic[name_line] = 1
        else:
            dic[name_line] += 1
        if name_line not in name_lines:
            name_lines.append(name_line)
    except:
        for item in name_lines[-8:]:
            print(item + " " + str(dic[item]))
        break