module Main where

import qualified System.IO as IO
import qualified List (sort, groupBy)

main =
  do IO.getContents >>= IO.putStr . unlines . (map format) . count . words

format :: (String,Int) -> String
format (s,l) = s ++ "  " ++ (show l)

count :: [String] -> [(String,Int)]
count = map (\ws->(head ws, length ws)) . List.groupBy (==) . List.sort

{-
   built-in functions:   unlines, words
-}