let genSafeWord = let rec num2alp num = match num with | 0 -> "" | num -> let alpSize = ('z' |> int) - ('a' |> int) let alpOffset = ('a' |> int) - 1 let n = match num%alpSize with | 0 -> alpSize | n -> n let s = (n + alpOffset) |> char |> string match n with | x when x = num -> s | x -> num2alp((num - n) / alpSize) + s let cnt=ref 1 let genWord startCharacter = let newWord = startCharacter + (num2alp cnt.Value) incr cnt newWord (fun (preWord:string) -> let preLastCharacter = preWord.ToCharArray() |> Array.last |> string let newWord = genWord preLastCharacter match newWord.ToCharArray()|> Array.last |> string with | "n" -> genWord preLastCharacter | _ -> newWord) let genOutWord (preWord:string) = let preLastCharacter = preWord.ToCharArray() |> Array.last |> string preLastCharacter + "n" let n = stdin.ReadLine() |> int Seq.unfold(fun (word,cnt)-> match cnt = (n-1) with | true -> let nextWord = genOutWord word Some(word, (nextWord, cnt + 1)) | _ -> let nextWord = genSafeWord word Some(word, (nextWord, cnt + 1))) ("a", 0) |> Seq.skip 1 |> Seq.take n |> Seq.iter(printfn "%s")