import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    n = inp()
    ans = [0 for _ in range(n)]
    ans[0] = 'a'
    ANS = []
    for n1 in range(0,n):
        for e1 in combinations(range(1,n),n1):
            for e in e1:
                ans[e] = 'a'
            list1 = deque()
            for i in range(1,n):
                if i not in e1:
                    list1.append(i)
            if list1:
                index = list1.popleft()
                ans[index] = 'b'
            if not list1:
                ANS.append(''.join(ans))
            for n2 in range(0,n-n1-1):
                for e2 in combinations(list1,n2):
                    for e in e2:
                        ans[e] = 'b'
                    list2 = deque()
                    for i in list1:
                        if i not in e2:
                            list2.append(i)
                    if list2:
                        index = list2.popleft()
                        ans[index] = 'c'
                    if not list2:
                        ANS.append(''.join(ans))
                    for n3 in range(0,n-n1-n2-2):
                        for e3 in combinations(list2,n3):
                            for e in e3:
                                ans[e] = 'c'
                            list3 = deque()
                            for i in list2:
                                if i not in e3:
                                    list3.append(i)
                            if list3:
                                index = list3.popleft()
                                ans[index] = 'd'
                            if not list3:
                                ANS.append(''.join(ans))
                            for n4 in range(0,n-n1-n2-n3-3):
                                for e4 in combinations(list3,n4):
                                    for e in e4:
                                        ans[e] = 'd'
                                    list4 = deque()
                                    for i in list3:
                                        if i not in e4:
                                            list4.append(i)
                                    if list4:
                                        index = list4.popleft()
                                        ans[index] = 'e'
                                    if not list4:
                                        ANS.append(''.join(ans))
                                    for n5 in range(0,n-n1-n2-n3-n4-4):
                                        for e5 in combinations(list4,n5):
                                            for e in e5:
                                                ans[e] = 'e'
                                            list5 = deque()
                                            for i in list4:
                                                if i not in e5:
                                                    list5.append(i)
                                            if list5:
                                                index = list5.popleft()
                                                ans[index] = 'f'
                                            if not list5:
                                                ANS.append(''.join(ans))
                                            for n6 in range(0,n-n1-n2-n3-n4-n5-5):
                                                for e6 in combinations(list5,n6):
                                                    for e in e6:
                                                        ans[e] = 'f'
                                                    list6 = deque()
                                                    for i in list5:
                                                        if i not in e6:
                                                            list6.append(i)
                                                    if list6:
                                                        index = list6.popleft()
                                                        ans[index] = 'g'
                                                    if not list6:
                                                        ANS.append(''.join(ans))
                                                    for n7 in range(0,n-n1-n2-n3-n4-n5-n6-6):  
                                                        for e7 in combinations(list6,n7):
                                                            for e in e7:
                                                                ans[e] = 'g'
                                                            list7 = deque()
                                                            for i in list6:
                                                                if i not in e7:
                                                                    list7.append(i)
                                                            if list7:
                                                                index = list7.popleft()
                                                                ans[index] = 'h'
                                                            if not list7:
                                                                ANS.append(''.join(ans))
                                                            for n8 in range(0,n-n1-n2-n3-n4-n5-n6-n7-7):  
                                                                for e8 in combinations(list7,n8):
                                                                    for e in e8:
                                                                        ans[e] = 'h'
                                                                    list8 = deque()
                                                                    for i in list7:
                                                                        if i not in e8:
                                                                            list8.append(i)
                                                                    if list8:
                                                                        index = list8.popleft()
                                                                        ans[index] = 'i'
                                                                    if not list8:
                                                                        ANS.append(''.join(ans))
                                                                    for n9 in range(0,n-n1-n2-n3-n4-n5-n6-n7-n8-8):  
                                                                        for e9 in combinations(list8,n9):
                                                                            for e in e9:
                                                                                ans[e] = 'i'
                                                                            list9 = deque()
                                                                            for i in list8:
                                                                                if i not in e9:
                                                                                    list9.append(i)
                                                                            if list9:
                                                                                index = list9.popleft()
                                                                                ans[index] = 'j'
                                                                            ANS.append(''.join(ans))
    ANS = list(set(ANS))
    ANS.sort()
    for i in range(len(ANS)):
        print(ANS[i])
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 122324