n = int(input())
verdict = [input() for i in range(n)]

opt_dict = {}

for j in verdict:
  if j not in opt_dict:
    opt_dict[j] = 0
    
  opt_dict[j] = opt_dict[j] + 1


for k, v in opt_dict.items():
  print(f"{k} x {v}")
  