type Card = (String, Int)
type Deck = [(Card, Bool)]

setupDeck :: Deck
setupDeck = [((m, n), False) | m <- ["S", "H", "C", "D"], n <- [1..13]]

updateDeck :: Card -> Deck -> Deck
updateDeck _ [] = []
updateDeck card@(m, n) (x@((m', n'), _):xs)
  | m == m' && n == n' = ((m, n), True):xs
  | otherwise          = x:(updateDeck card xs)

readCards :: Int -> Deck -> IO Deck
readCards 0 deck = return deck
readCards n deck = getLine >>= return.words >>= \[m, i] -> readCards (n - 1) $ updateDeck (m, read i :: Int) deck

printLackCards :: Deck -> IO ()
printLackCards [] = return ()
printLackCards (((m, n), r):xs)
  | not r     = putStrLn (m ++ " " ++ show n) >> printLackCards xs
  | otherwise = printLackCards xs

main :: IO ()
main = do
    n <- getLine >>= \n -> return (read n :: Int)
    readCards n setupDeck >>= printLackCards

