a = int(input())
list1 = []
dict1 = {}
for x in range(a):
    b = input()
    list1.append(b)

for x in list1:
    if x not in dict1:
        dict1[x] = 1
    else:
        dict1[x] += 1

for x in dict1:
    print(f'{x} x {dict1[x]}')