fun main() {
    class Type(val raw: String = "", val value: String = "", val i: Int = 0, val map: Map<Char, Int> = emptyMap()) {
        fun append(c: Char): Type {
            val m = map.toMutableMap()
            val index = m.getOrPut(c, { i + 1 })
            return Type(raw + c, value + index, i + 1, m)
        }
    }

    val n = readLine()?.toInt() ?: return
    val set = listOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j').take(n)
    val standard = hashMapOf<String, String>()
    fun gen(n: Int, r: Int, set: List<Char>, s: Type) {
        if (s.raw.length == n) {
            val key = s.value
            if (!standard.containsKey(key)) {
                standard[key] = s.raw
            }
        } else {
            set.take(n - r).forEachIndexed { i, c ->
                gen(n, r - if (i == n - r - 1) 1 else 0, set, s.append(c))
            }
        }
    }
    gen(n, n - 1, set, Type())
    buildString {
        standard.values.sorted().forEach {
            appendln(it)
        }
    }.let {
        println(it.trimIndent())
    }
}
