import Data.List parseInput :: String -> [(Char, Int)] parseInput = zip ['A'..] . map read . lines process :: [(Char, Int)] -> [Char] process = map fst . sortBy (\(_, x) (_, y) -> compare y x) output :: [Char] -> IO () output = mapM_ (putStrLn . (:[])) main :: IO () main = getContents >>= output . process . parseInput