let rec nfs cand acc m = function
  | 0 -> List.rev cand :: acc
  | n ->
      nfs (Char.chr (Char.code 'a' + m) :: cand)
        (Array.fold_left
          (fun acc i -> nfs (Char.chr (Char.code 'a' + i) :: cand) acc m (n - 1)) acc
          (Array.init m @@ fun i -> i))
        (m + 1) (n - 1)
let nfs = nfs [] [] 0

let () = Scanf.scanf "%d\n" @@ fun n ->
  List.iter (fun cs ->
    List.iter print_char cs;
    print_newline ()) @@
  List.sort compare @@ nfs n