n = gets.to_i
str = 'abcdefghij'
str[0...n].split(//).repeated_permutation(n).to_a.uniq { |s|
  hash = {}
  num = 0
  s.map{|a| 
    if hash[a].nil?
      hash[a] = num
      num += 1
    end
    hash[a]
  }
}.each { |s|
  p s.join
}
