import sys, collections, psyco

def main():

  score = collections.defaultdict(int)

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

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

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

