import Data.List main = getLine >> getContents >>= putStrLn . head . foldl ff (map show [0..9]) . map words . lines where ff acc (a : b : c : d : r : _) | r == "NO" = acc \\ [a, b, c, d] | otherwise = filter (`elem` [a, b, c, d]) acc