package main

import (
	"fmt"
)

var len = 0

func main() {
	var N int
	fmt.Scanf("%d", &N)
	strs := make([]string, fac(N))
	add(strs, "", 0, N)
	for i, s := range strs {
		if i == len {
			break
		}
		fmt.Println(s)
	}
}
func add(strs []string, s string, d, N int) {
	if d == N {
		if check(s) {
			strs[len] = s
			len++
		}
		return
	}
	for i := 0; i <= d; i++ {
		add(strs, string(append([]rune(s), rune('a'+i))), d+1, N)
	}
}
func check(s string) bool {
	m := map[rune]int{}
	max := 'a'
	for _, r := range []rune(s) {
		m[r]++
		if r > max {
			max = r
		}
	}
	for i := 'a'; i < max; i++ {
		if m[i] < 1 {
			return false
		}
	}
	return true
}

func fac(N int) int {
	if N == 1 {
		return 1
	}
	return fac(N-1) * N
}
