n = int(input())
word_dict = {}
for _ in range(n):
  word = str(input())
  if word in word_dict:
    word_dict[word] += 1
  else:
    word_dict[word] = 1
for k, v in word_dict.items():
  print(k, 'x', v)