import sys

all_names = []
save={}
save_list = []
for line in sys.stdin:
    name, size = line.split()
    if name+' '+size in all_names:
        continue
    else:
        all_names.append(name)
        onlyname = name.split('\\')[-1]
        if len(onlyname)> 16:
            onlyname = onlyname[-16:]
        if onlyname+' '+size in save.keys():
            save[onlyname+' '+size]+=1
        else:
            save[onlyname+' '+size]=1
            if len(save_list)<8:
                save_list.append(onlyname+' '+size)
            else:
                save_list.pop(0)
                save_list.append(onlyname+' '+size)


for i in save_list:
    print(i,save[i])