import Control.Applicative ((<$>)) import Data.List (sort, intercalate) main :: IO () main = getLine >> solve <$> (words <$> getLine) >>= putStrLn solve :: [String] -> String solve = intercalate " " . map show . sort . map toTramp data Mark = D | C | H | S deriving (Eq, Ord, Show, Read) data Value = Value Int deriving (Eq, Ord) data Tramp = Tramp Mark Value deriving (Eq, Ord) instance Show Value where show (Value 1) = "A" show (Value 10) = "T" show (Value 11) = "J" show (Value 12) = "Q" show (Value 13) = "K" show (Value x) = show x instance Show Tramp where show (Tramp m v) = show m ++ show v toValue :: String -> Value toValue "A" = Value 1 toValue "T" = Value 10 toValue "J" = Value 11 toValue "Q" = Value 12 toValue "K" = Value 13 toValue x = Value (read x) toTramp :: String -> Tramp toTramp [m,v] = Tramp (read [m]) (toValue [v])