import Data.List main :: IO () main = getContents >>= mapM_ putStrLn . map snd . reverse . sort . flip zip ["A", "B", "C"] . map toint . lines toint :: String -> (Int, Int) toint u = (read x, negate . read $ y) where [x, y] = words u