import           Control.Applicative
import           Data.Functor
import qualified Data.List           as L
import qualified Data.Set            as S

main :: IO ()
main = do
  n <- readLn
  cards <- solve n allCards
  mapM_ (putStrLn . show) cards

solve :: Int -> S.Set Card -> IO [Card]
solve 0 s = pure $ L.sort $ S.toList s
solve n s = do
  ws <- words <$> getLine
  let card = parseCard ws
  solve (n-1) (S.delete card s)

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

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

data Card
  = Card CardKind Int
  deriving (Eq)

instance Ord Card where
  Card ck1 n1 `compare` Card ck2 n2 =
    case ck1 `compare` ck2 of
      EQ -> n1 `compare` n2
      _  -> ck1 `compare` ck2

instance Show Card where
  show (Card ck n) = show ck ++ " " ++ show n

allCards :: S.Set Card
allCards = S.fromList $ do
  cardKind <- [Spade, Heart, Club, Diamond]
  number <- [1..13]
  pure $ Card cardKind number

parseCard :: [String] -> Card
parseCard [c',n'] = Card c (read n')
  where
    c = case c' of
      "S" -> Spade
      "H" -> Heart
      "C" -> Club
      "D" -> Diamond

