{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import Control.Monad
import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [n] <- readInts
  replicateM n readStrings >>= output . solve . map head

solve :: [String] -> [(String, Int)]
solve = map f . L.group . L.sort
  where
    f ys = (head ys, length ys)

output :: [(String, Int)] -> IO ()
output xs = do
  putStrLn $ fmt "AC" xs
  putStrLn $ fmt "WA" xs
  putStrLn $ fmt "TLE" xs
  putStrLn $ fmt "RE" xs
  where
    fmt s xs =
      case lookup s xs of
        Nothing -> s <> " x 0"
        Just n -> s <> " x " <> show n 

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine

readStrings :: IO [String]
readStrings = map C8.unpack . C8.words <$> C8.getLine