N = gets.chomp.to_i

S = ("a".."z").to_a
ans = []

def print_s(s)
  s.map{|v| S[v]}.join
end

def combi(nums, len, ary)
  res = [ary.dup]
  max_num = nums[-1]
  last = Array.new(len, max_num)
  loop do
    break if ary == last
    ary[-1] += 1
    # 繰り上がり
    if ary[-1] > max_num
      ary[-1] = 0
      1.upto(len-1) do |i|
        ary[-1-i] += 1
        break if ary[-1-i] <= max_num
        ary[-1-i] = 0
      end
    end
    res << ary.dup
  end
  res
end

s = Array.new(N, 0)
puts print_s(s)
# 使う文字種数 i-1
1.upto(N-1) do |i|
  (0..i-1).each{|j| s[j] = j}
  s[N-1] += 1
  nums = (0..i).to_a
  c = combi(nums, N-i, s[i..N-1])
  c.each do |t|
    s[i..N-1] = t
    puts print_s(s)
  end

end
