import sys, psyco

def main():

  total = {}

  for line in sys.stdin:
    for word in line.split():
      if word in total:
        total[word] += 1
      else:
        total[word] = 1

  for word in sorted(total.keys()):
    print word, total[word]

if __name__ == "__main__":
   psyco.full()
   main()
