import Data.List main = getLine >> getContents >>= putStrLn . solve . map words . lines solve :: [[String]] -> String solve = head . foldl (\acc [a, b, c, d, r] -> if r == "NO" then acc \\ [a, b, c, d] else [a, b, c, d] \\ acc) (map show [0..9])