import Data.List main = do getLine nrs <- map ((\xs -> (map read (init xs), last xs)) . words) . lines <$> getContents print (kazuate nrs) kazuate = head . foldr guess [0..9] where guess (ns,"YES") acc = intersect ns acc guess (ns,"NO") acc = acc \\ ns