package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	_, _ = fmt.Scanf("%d", &n)
	m := map[string]int{"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

	for i := 0; i < n; i++ {
		var ans string
		_, _ = fmt.Scanf("%s", &ans)
		m[ans]++
	}

	mSorted := map[int]string{}
	mKeys := []int{}
	for k, v := range m {
		mSorted[v] = k
		mKeys = append(mKeys, v)
	}
	sort.Slice(mKeys, func(i, j int) bool {
		return mKeys[i] > mKeys[j]
	})
	for _, v := range mKeys {
		fmt.Printf("%s x %d\n", mSorted[v], v)
	}
}
