import Data.List import qualified Data.Set as S main = putStrLn . head . S.elems . foldl f (S.fromList $ map show [0..9]) . map (splitAt 4 . words) . drop 1 . lines =<< getContents where f s (l,["YES"]) = S.intersection s $ S.fromList l f s (l,["NO"]) = S.difference s $ S.fromList l