import Control.Monad (replicateM) toInt x = read x :: Int disammble s = (map toInt (init s), last s) judge cand phrase = if snd phrase == "NO" then [x | x <- cand, x `notElem` fst phrase] else [x | x <- fst phrase, x `elem` cand] main = do n <- readLn input <- replicateM n getLine let mind = map words input let res = foldl judge [0 .. 9] (map disammble mind) print $ head res