import Data.List import Control.Applicative import Control.Monad main = do n <- readLn names <- replicateM n getLine let newNames = filter regal (permutations "inabameguru") \\ names case newNames of [] -> putStrLn "NO" _ -> putStrLn $ head newNames regal [] = True regal [charo] = if charo `elem` "iaeu" then True else False regal (charo1 : charo2 : str) = if charo1 `elem` "iaeu" then regal (charo2 : str) else if charo2 `elem` "nbmgr" then False else regal str