#!/usr/bin/env python
import sys
authors = {}
for line in sys.stdin:
    if line[0] != 'r':
        continue
    author = line.split()[2]
    if author not in authors:
        authors[author] = 0
    authors[author] += 1
for author in sorted(authors):
    print author, authors[author]
