n = int(input(""))

dic = dict()
lst = list()

for i in range(n) : 
    op = input("")
    lst.append(op)


for word in lst:
    dic[word] = dic.get(word,0) + 1

for words in dic:
    print(words, "X",dic[words])
     