import Data.List (intersect) sortedCards :: [String] sortedCards = concatMap (\s -> map (s :) nums) suits where suits = ['D', 'C', 'H', 'S'] nums = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"] main :: IO () main = getLine >> getLine >>= putStrLn . unwords . (intersect sortedCards) . words