using System; using System.Collections.Generic; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; string targetstr = "inabameguru"; int inputCount =int.Parse( Reader.ReadLine()); for (int i=0; i boin = new List(); List shiin = new List(); List boinList = new List( new char[]{'a', 'i','u','e','o'}); for(int i=0; i list = this.getAns(boin, shiin, true, string.Empty); foreach (string newName in list) { if(!NGList.Contains(newName)) { Console.WriteLine(newName); break; } } } private bool MustQuit = false; private Dictionary>>> dic = new Dictionary>>>(); private List getAns(List boin, List shiin, bool isPrevBoin, string totyu) { string keyBoin = string.Join("", boin); string keyShiin = string.Join("", shiin); if(!dic.ContainsKey(keyBoin)) { dic.Add(keyBoin, new Dictionary>>()); } if(!dic[keyBoin].ContainsKey(keyShiin)) { dic[keyBoin].Add(keyShiin,new Dictionary>()); } if(dic[keyBoin][keyShiin].ContainsKey(isPrevBoin)) { return dic[keyBoin][keyShiin][isPrevBoin]; } List ans = new List(); if(MustQuit) { return ans; } if(boin.Count == 1 && shiin.Count == 0) { string ret = totyu + boin[0]; if(!NGList.Contains(ret)) { Console.WriteLine(ret); MustQuit = true; return ans; } ans.Add(boin[0].ToString()); } else if(boin.Count == 0 && shiin.Count > 0) { } else if(shiin.Count > boin.Count) { } else { for(int i=0; i subBoin = new List(boin); subBoin.RemoveAt(i); List ret = this.getAns(subBoin, shiin, true, totyu + boin[i]); if(ret.Count > 0) { ret.ForEach(a=>ans.Add(boin[i] + a)); string tmp = ret.Select(a=>totyu + boin[i] + a).Where(b=> !this.NGList.Contains(b)).First(); if(tmp != null) { Console.WriteLine(tmp); MustQuit = true; } } if(MustQuit) { return ans; } } if(isPrevBoin) { for(int i=0; i subShin = new List(shiin); subShin.RemoveAt(i); List ret = this.getAns(boin, subShin, false, totyu +shiin[i]); if(ret.Count > 0) { ret.ForEach(a=>ans.Add(shiin[i] + a)); string tmp = ret.Select(a=>totyu + boin[i] + a).Where(b=> !this.NGList.Contains(b)).First(); if(tmp != null) { Console.WriteLine(tmp); MustQuit = true; } } if(MustQuit) { return ans; } } } } this.dic[keyBoin][keyShiin].Add(isPrevBoin, ans); return ans; } private List NGList = new List(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 3 inabameguru meguruinaba nemuriugaba "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ', bool trim = false) { string inptStr = ReadLine(); if (trim) { inptStr = inptStr.Trim(); } string[] inpt = inptStr.Split(delimiter); int[] ret = new int[inpt.Length]; for (int i = 0; i < inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } static void Main() { Program prg = new Program(); prg.Proc(); } }