{-# LANGUAGE NamedFieldPuns #-}
import Control.Monad (replicateM)
import Data.Foldable (traverse_)
import Data.Functor ((<$>))
import Data.List ((\\), sort)

data Suit = Spade | Heart | Club | Diamond
  deriving (Eq, Ord, Enum)

instance Show Suit where
  show Spade   = "S"
  show Heart   = "H"
  show Club    = "C"
  show Diamond = "D"

readSuit "S" = Spade
readSuit "H" = Heart
readSuit "C" = Club
readSuit "D" = Diamond

data Card = Card { suit :: Suit, rank :: Int }
  deriving (Eq, Ord)

instance Show Card where
  show (Card{suit, rank}) = show suit ++ " " ++ show rank

readCard str =
  let [s, r] = words str
  in Card { suit = readSuit s, rank = read r }

allCards = do
  ss <- [Spade .. Diamond]
  rs <- [1..13]
  return $ Card { suit = ss, rank = rs }

main = do
  n <- readLn
  cards <- replicateM n (readCard <$> getLine)
  traverse_ print $ sort $ allCards \\ cards

