import sys

input=lambda: sys.stdin.readline().rstrip()

n=int(eval(input()))



def f(x):

  A=[]

  for _ in range(n):

    A.append(x%10)

    x//=10

  return A[::-1]



def g(X):

  cur=X[0]

  ret=-1

  for i in range(1,n):

    if X[i]+1<=cur+1 and X[i]+1<=i:

      ret=i

    cur=max(cur,X[i])

  return ret

Ans=[0]



a=f(0)

b=g(a)

while b>=0:

  next=0

  for i in range(n):

    if i<b:

      next+=a[i]*(10**(n-1-i))

    elif i==b:

      next+=(a[i]+1)*(10**(n-1-i))

  Ans.append(next)

  a=f(next)

  b=g(a)

for a in Ans:

  ans=""

  for x in f(a):

    ans+=chr(97+x)

  print(ans)











import sys

input=lambda: sys.stdin.readline().rstrip()

n=int(eval(input()))

A=[chr(97+int(i)) for i in range(n)]



Ans=["a"]

if n>=2:

  for _ in range(n-1):

    Ans2=[]

    for a in Ans:

      s=set()

      for aa in a:

        s.add(aa)

      ss=len(s)

      for i in range(ss+1):

        Ans2.append(a+A[i])

    Ans=Ans2

Ans.sort()

for ans in Ans:

  print(ans)
import sys

input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))


def f(x):
    A = []
    for _ in range(n):
        A.append(x % 10)
        x //= 10
    return A[::-1]


def g(X):
    cur = X[0]
    ret = -1
    for i in range(1, n):
        if X[i] + 1 <= cur + 1 and X[i] + 1 <= i:
            ret = i
        cur = max(cur, X[i])
    return ret


Ans = [0]
a = f(0)
b = g(a)
while b >= 0:
    next = 0
    for i in range(n):
        if i < b:
            next += a[i] * (10 ** (n - 1 - i))
        elif i == b:
            next += (a[i] + 1) * (10 ** (n - 1 - i))
    Ans.append(next)
    a = f(next)
    b = g(a)
for a in Ans:
    ans = ""
    for x in f(a):
        ans += chr(97 + x)
    print(ans)

import sys

input = lambda: sys.stdin.readline().rstrip()
n = int(eval(input()))
A = [chr(97 + int(i)) for i in range(n)]
Ans = ["a"]
if n >= 2:
    for _ in range(n - 1):
        Ans2 = []
        for a in Ans:
            s = set()
            for aa in a:
                s.add(aa)
            ss = len(s)
            for i in range(ss + 1):
                Ans2.append(a + A[i])
        Ans = Ans2
Ans.sort()
for ans in Ans:
    print(ans)

- - -def f(x): -    A = [] -    for _ in range(n): -        A.append(x % 10) -        x //= 10 -    return A[::-1] - - -def g(X): -    cur = X[0] -    ret = -1 -    for i in range(1, n): -        if X[i] + 1 <= cur + 1 and X[i] + 1 <= i: -            ret = i -        cur = max(cur, X[i]) -    return ret - - -Ans = [0] -a = f(0) -b = g(a) -while b >= 0: -    next = 0 -    for i in range(n): -        if i < b: -            next += a[i] * (10 ** (n - 1 - i)) -        elif i == b: -            next += (a[i] + 1) * (10 ** (n - 1 - i)) -    Ans.append(next) -    a = f(next) -    b = g(a) -for a in Ans: -    ans = "" -    for x in f(a): -        ans += chr(97 + x) +A = [chr(97 + int(i)) for i in range(n)] +Ans = ["a"] +if n >= 2: +    for _ in range(n - 1): +        Ans2 = [] +        for a in Ans: +            s = set() +            for aa in a: +                s.add(aa) +            ss = len(s) +            for i in range(ss + 1): +                Ans2.append(a + A[i]) +        Ans = Ans2 +Ans.sort() +for ans in Ans: