Scanf.scanf "%d" (fun n ->
    let arr = Array.make n ' ' in
    let rec loop i c mx =
        if i = n then print_endline @@ String.init n (fun i -> arr.(i)) else
            if c > mx then () else (
                arr.(i) <- char_of_int c;
                loop (i + 1) 97 (max mx (c + 1));
                loop i (c + 1) mx
            )
    in
    loop 0 97 97
)