#!/usr/bin/env python

"""
Gives statistics about stretches of characters annotated O.
"""

import sys

from collections import Counter
from itertools import chain

instretch = False
counter = Counter()
current_length = 0
stretches = []

for line in chain(sys.stdin, ['0 S']):
    line = line.rstrip()
    if not line:
        continue
    char, label = line.split(' ')
    char = int(char)
    if instretch:
        if label == 'O':
            current_length += 1
            current_stretch += unichr(char)
        else:
            instretch = False
            counter[current_length] += 1
            stretches.append(current_stretch)
    else:
        if label == 'O':
            instretch = True
            current_length = 1
            current_stretch = unichr(char)
        else:
            pass

lengths = list(counter.keys())
lengths.sort()

for length in lengths:
    print length, counter[length]

#for stretch in stretches:
#    if len(stretch) == 3:
#        print stretch
