peterverebics/CodeNet_Python_118 huggingface dataset:
n = int(input())
ans = []
start = "a"
stack = []
stack.append(start)
num = ord("a")
while stack:
    v = stack.pop()
    if len(v) == n:
        ans.append(v)
        continue
    s = list(v[::])
    s.sort()
    nex_num = ord(s[-1])
    for i in range(num, nex_num + 2):
        tuika = chr(i)
        stack.append(v + tuika)
print(*ans[::-1], sep="\n")
from itertools import combinations_with_replacement

N = int(input())
C = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
DP = [set() for _ in range(N)]
DP[0].add((1, 'a'))

for i in range(1, N):
    for num, s in DP[i-1]:
        for j in range(num):
            DP[i].add((num, s + C[j]))
        DP[i].add((num + 1, s + C[num]))
A = []
for _, ax in DP[N-1]:
    A.append(ax)
A.sort()
for a in A:
    print(a)
import sys, math
input = sys.stdin.readline
N = int(input())

dic = 'abcdefghijklmnopqrstuvwxyz'

def f(n, i, s):
  if n == 1:
    print(s)
    return
  for j in range(i+1):
    f(n-1, i, s + dic[j])
  if i+1 < 25:
  	f(n-1, i+1, s + dic[i+1])

f(N, 0, 'a')
import sys
sys.setrecursionlimit(10**7)
def dfs(s,m):
    if len(s)==N:
        li.append(s)
        return
    for c in range(97,ord(m)+2):
        dfs(s+chr(c),max(m,chr(c)))

N=int(input())
li=[]
li.sort()
dfs('a','a')
print(*li,sep='\n')
import string
ans = []
N = int(input())

def rec(s, i):
    if len(s) == N:
        ans.append(s)
        return

    for c in string.ascii_lowercase[:i + 1]:
        if c == string.ascii_lowercase[i]:
            rec(s + c, i + 1)
        else:
            rec(s + c, i)

rec("a", 1)
for x in ans:
    print(x)
alpha = "abcdefghij"
n = int(input())
def dfs(s,k):
    if len(s) == n:
        print(s)
    else:
        for i in range(k+1):
            if i == k:
                dfs(s+alpha[i],k+1)
            else:
                dfs(s+alpha[i],k)
dfs("",0)
import itertools as iters

def enlong(s,m):
    return [s + [i] for i in range(1,m+2)]

N = int(input())
alpha = "abcdefghijk"
R = [[1]]
for _ in range(N-1):
    S = []
    for r in R:
        S += enlong(r,max(r))
    R = S[::]
for r in R:
    s = "".join([alpha[ss-1] for ss in r])
    print(s)
N = int(input())
def calc(n, L, ma):
    if n == 0: 
        print("".join([chr(a+97) for a in L]))
        return L
    for i in range(ma+2):
        l = calc(n-1, L + [i], max(ma, i))

calc(N, [], -1)
A = [ [ ] for i in range(11)]
A[1].append('a')
n = 1
for i in range(1,10):
    B = A[i]
    for b in B:
        x = 0
        for k in range(i):
            c = b[k]
            x = max(ord(c),x)
        for j in range(97,x+2):
            d = b + chr(j)
            A[i+1].append(d)
N = int(input())
for a in A[N]:
    print(a)
alphabet = [chr(i) for i in range(97, 97+26)]
ans = []
N = int(input())


def makeS(S, now):
    if len(S) == N:
        ans.append(S)
        return
    for i, c in enumerate(alphabet[:now+1]):
        if i == now:
            makeS(S+c, now + 1)
        else:
            makeS(S+c, now)


makeS('a', 1)
for s in sorted(ans):
    print(s)
import string

N = int(input())
S = string.ascii_letters[:N] 
S_idx = {s:i for i, s in enumerate(S)}

def main(s, n):
    if n >= N:
        return print(s)
    idx =  S_idx[max(s)]
    for i in S[:idx+2]:
        main(s+i, n+1)
        
main('a', 1)
N = int(input())
alph = list("abcdefghij")
ans = []

if N == 1: print("a")
def roop(root,use):
    if len(root) != N:
        for i in range(use+1):
            ans = root + alph[i]
            roop(ans,max(i+1,use))
            if len(ans) == N:
                print(ans)

roop("a",1)
n = int(input())
ans = ['a'] # 最初の一文字は'a'で固定

for i in range(n-1): # 'a'に'n-1'文字分ループで足す
    tmp = [] # リセット
    for j in ans:
        l = len(set(j)) # 'j'の使用文字種の数をカウント
        for k in range(l+1): # 'j'の使用文字種の数 '+1'回ループして...
            tmp.append(j + chr(ord('a') + k)) # 'j'に appendする
    ans = tmp[:] # 'ans'を書き換える

for i in ans:
    print(i)
'''
Created on 2020/09/09

@author: harurun
'''

def dfs(s,t,N):
  if len(s)==N:
    print(s)
  else:
    c=97
    while c<=ord(t):
      if c==ord(t):
        dfs(s+chr(c),chr(ord(t)+1),N)
      else:
        dfs(s+chr(c),t,N)
      c+=1
  return

def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  dfs("",'a',N)
  return

main()

##解説AC
N = int(input())

lst = []

d = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(s, i):
    if len(s) == N:
        print(s)
        return

    for k in range(i):
        dfs(s + d[k], i)

    dfs(s+d[i], i + 1)


dfs('', 0)
import itertools
#再帰関数のときのRE予防
import sys
sys.setrecursionlimit(312467) 
N = int(input())
List = []
def dfs(S):
    List.append(S)
    if len(S) < N:
      for i in range(ord("a"), ord(max(S))+2):
        dfs(S+[chr(i)])
    return
dfs(["a"])
for i in List:
  if len(i) == N:
    print("".join(i))
  elif len(i) > N:
    break
import math

n = int(input())

x = ["a"]
alps = "abcdefghijk"
i = 1
while i < n:
    y = []
    for t in x:
        for s in alps[:len(set(t)) + 1]:
            y.append(t + s)
    x = y
    i += 1

print("\n".join(x))
n = int(input())

alpha = [chr(i) for i in range(97, 97+26)]

def dfs(s, mx):
    if(len(s)==n):
        print(s)
    else:
        for i in range(mx):
            if i==mx-1:
                dfs(s+alpha[i], mx+1)
            else:
                dfs(s+alpha[i], mx)

dfs("",1)
N = int(input())

def dfs(x):
    if len(x) == N:
        s = "".join(chr(v + ord("a")) for v in x)
        print(s)
        return

    val = max(x)
    for i in range(val + 2):
        x.append(i)
        dfs(x)
        x.pop()

dfs([0])
n = int(input())

strings = ["a"]

for i in range(n-1):
    newstrings = []
    for s in strings:
        mx = ord('a')
        for char in s:
            mx = max(mx, ord(char))
        
        for c in range(ord('a'),mx+2):
            newstrings.append(s+chr(c))
    
    strings = newstrings

for s in strings:
    print(s)
# D - String Equivalence
abc = "abcdefghij"


def dfs(n: int) -> list:
    if n == 1:
        return ["a"]
    cur = dfs(n - 1)
    result = []
    for s in cur:
        for c in abc[: len(set(s)) + 1]:
            result.append(s + c)
    return result


def main():
    N = int(input())
    result = dfs(N)
    result.sort()
    print("\n".join(result))


if __name__ == "__main__":
    main()
N = int(input())
ans = []
char = ["a"]


def dfs(idx, c):
    if idx == N:
        ans.append("".join(char))
    else:
        for i in range(c+2):
            nc = chr(ord("a")+i)
            char.append(nc)
            dfs(idx+1, max(i, c))
            char.pop()

dfs(1, 0)
for i in range(len(ans)):
    print(ans[i])
n = int(input())
 
def aa(str, chrMax):
  if len(str) == n:
    print(str)
    return
  for i in range(ord("a"), ord(chrMax)+2):
    if i > ord(chrMax):
      aa(str+chr(i), chr(i))
    else:
      aa(str+chr(i), chrMax)
 
aa("a", "a")
n=int(input())

from collections import deque

option=deque()
option.append("a")
ans=[]

while option:
    s=option.pop()
    if len(s)==n:
        ans.append(s)
        continue
    maxi=0
    for i in s:
        maxi=max(maxi,ord(i))
        
    for i in range(97,maxi+2):
        new_s=s+chr(i)
        if new_s not in option and len(new_s)<=n:
            option.append(new_s)

ans=sorted(ans)
for i in ans:
    print(i)
n = int(input())
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  alpha_dict[i] = str(chr(c)).lower()


ans = []
def dfs(s, mx, ans):
  if len(s) == n:
    ans += [s]
    return 
  else:
    for i in range(mx+2):
      dfs(s+alpha_dict[i], max(i, mx), ans)

dfs("", -1, ans)
ans = sorted(ans)
for a in ans:
  print(a)
N = int(input())

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 2):
            new_answer.append((max(k, i), j + chr(k)))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))
alphabet = "abcdefghijklmnopqrstuvwxyz"
alphabet_i = {v:i for i,v in enumerate("abcdefghijklmnopqrstuvwxyz")}
N = int(input())
ans = []

memo = {}

def dfs(tmp,i):
    if i == N:
        ans.append(tmp)
        return

    maxi = max([alphabet_i[c] for c in tmp])
    for c in alphabet[:maxi+2]:
        dfs(tmp+c, i+1)

dfs("a", 1)
for s in ans:
    print(s)
def DFS(word,n):
    if len(word)==N:print(word)
    else:
        for i in range(n+1):
            DFS(word+chr(97+i),n+1 if i==n else n)


N=int(input())
DFS("",0)
n = int(input())
r = 'a',
for _ in range(n - 1):
  r = [s + c for s in r for i, c in enumerate(s + chr(ord(max(s)) + 1)) if c not in s[:i]]
print(*r, sep='\n')
N = int(input())
W = 'abcdefghij'
ans = set()

for i in range(1,N+1):
  if i == 1:
    ans.add('a')
  else:
    tmp = set()
    for a in ans:
      index = W.index(sorted(list(a))[-1])
      for i in range(index+2):
        tmp.add(a+W[i])
    ans = tmp
    
for a in sorted(ans):
  print(a)
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**9)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

al = ['a','b','c','d','e','f','g','h','i','j']

import copy
n = ni()

def f(a,b,m):
  if a == n:
    print(''.join([al[i] for i in b]))
  else:
    for i in range(m+2):
      c = copy.copy(b)
      c.append(i)
      f(a+1,c,max(m,i))

f(1,[0],0)
import sys
sys.setrecursionlimit(1000000)


def dfs(s):
    if len(s) == n:
        print(s)
        return
    kind = len(set(s))
    for i in range(kind + 1):
        dfs(s + chr(ord('a') + i))


n = int(input())
dfs('')
N = int( input() )
alphabets = "abcdefghij"[ :N ]
types= ["a"]

for _ in range(N-1):
  for j in range(len(types)):
    target=types.pop(0)
    #print(set(target))
    for k in range(len(set(target))+1):
      types.append(target+alphabets[k])
    #print(types)
types.sort()
for each in types:
  print(each)
def rec(pos, used, s):
    if pos == n:
        print(s)
        return
    for i in range(used):
        rec(pos + 1, used, s + chr(ord('a') + i))
    rec(pos + 1, used + 1, s + chr(ord('a') + used))

n = int(input())
rec(0, 0, "")
import collections

N = int(input())

W = ["a"]
nW = []

"""
k = len(collections.Counter(Y[0]))
print(k)
"""
for j in range(N-1):
    for w in W:
        k = len(collections.Counter(w))
        for i in range(k+1):
            nW.append(w + chr(i+97))
    W = nW.copy()
    nW.clear()
    
    # print("N=",j+2)
# print(W[-1])

for i in W:
    print(i)
import sys
readline = sys.stdin.buffer.readline

n = int(readline())

alphabets = [chr(ord('a') + x) for x in range(26)]

def dfs(s,i):
    if len(s)==n:
        print("".join(s))
    else:
        t = min(len(set(s))+1,len(s)+1)
        for i in range(t):
            dfs(s+[alphabets[i]],i)

dfs([],0)
N = int(input())

lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']


def dfs(ans, keep, n):
    if n == N + 1:
        print(ans)
    else:
        for i in range(keep):
            dfs(ans + lis[i], max(keep, i + 2), n + 1)


dfs('', 1, 1)
#!/usr/bin/env python
# coding: utf-8

# In[70]:


N = int(input())


# In[71]:


num2alpha = lambda c: chr(c%26+97)


# In[72]:


def dfs(s,n,cnt):
    if n == 0:
        print(s)
        return
    for i in range(cnt+2):
        if i == cnt+1:
            dfs(s+num2alpha(i),n-1,cnt+1)
        else:
            dfs(s+num2alpha(i),n-1,cnt)
dfs("a",N-1,0)


# In[ ]:
def f(word,n):
    if len(word)==N:return print(word)
    else:
        for i in range(n+1):
            f(word+chr(97+i),n+1 if i==n else n)


N=int(input())
f("",0)
N = int(input())

def dfs(s, mx):
  if len(s) == N:
    print(s)
  else:
    for i in range(ord('a'), ord(mx)+1):
      dfs(s+chr(i), chr(ord(mx)+1) if chr(i) == mx else mx)
      
dfs('', 'a')
n = int(input())
alphabet = 'abcdefghijk'

def ans(n):
    if n == 1:
        return ['a']
    ret = []
    pre = ans(n-1)
    for s in pre:
        l = len(set(s))
        for i in range(l+1):
            ret.append(s + alphabet[i])
    return ret

for s in ans(n):
    print(s)
# -*- coding: utf-8 -*-

def dfs(s, mx, N):
    if len(s) == N:
        print(s)
    else:
        for i in range(97, ord(mx) + 1):
            dfs(s + chr(i), chr(max(i + 1, ord(mx))), N)

N = int(input())

dfs('', 'a', N)
n = int(input())
ans = []

def dfs( s , mx ):
    if len(s) == n:
        ans.append(s)
        return
    else:
        for j in range(mx+1):
            t = chr(j + 97)
            mx2 = ord(max(s+t)) - 96
            dfs( s+t , mx2 )
            
dfs('a' , 1)

for i in ans:
    print(i)
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n = int(input())
  def dfs(s, mx):
    if len(s) == n:
      print(s)
      return
    for c in range(ord('a'), ord(mx)+1):
      dfs(s + chr(c), (chr(ord(mx) + 1) if ord(mx) == c else mx))
  dfs('', 'a')
      
if __name__=='__main__':
  main()
n = int(input())

s = ['a']*(n)
#print(''.join(s))

def dfs(x,alp):
    if x == n:
        print(''.join(s))
        return
    
    for i in range(alp+1):
        #print(x,alp,i)
        s[x] = chr(i+ord("a"))
        dfs(x+1,max(i+1,alp))
        #print(alp)


dfs(0,0)
n = int(input())
def dfs(s):
  if len(s) == n:
    print(s)
  else:
    max_list = []
    for _ in s:
      max_list.append(ord(_))
    for i in range(ord("a"),max(max_list) + 2):
      s = s + chr(i)
      dfs(s)
      s = s[:len(s) - 1]
      
dfs("a")
n=int(input())
a=[[] for i in range(n)]
a[0]=[0]
k=0
s=['a']*n
t=[0]*n
while k>=0:
  if a[k]==[]:
    k-=1
    continue
  t[k]=a[k].pop(0)
  s[k]=chr(ord('a')+t[k])
  if k==n-1:
    print("".join(s))
  else:
    k+=1
    a[k]+=list(range(max(t[:k])+2))
import sys,math
sys.setrecursionlimit(10**9)
import itertools
from collections import defaultdict
 
IA = lambda: map(int,input().split())
IAS= lambda: map(str,input().split())


n=int(input())


def dfs(s,lim):

    
    if len(s)==n:
        print(s)
    else:
        for i in range(ord('a'),ord(lim)+1):
            
            if i==ord(lim):
                dfs(s+chr(i),chr(ord(lim)+1))
            else:
                dfs(s+chr(i),lim)

dfs('','a')
n = int(input())
s=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
x=[j for j in range(n)]
from collections import deque
import copy
old_stack=deque(['a'])
x=1
while old_stack:
    s=old_stack.popleft()
    if len(s)==n:
        old_stack.appendleft(s)
        break
    for i in range(ord(max(s))-ord('a')+2):
        old_stack.append(s+chr(ord('a')+i))

for o in old_stack:    
    print(o)
def dfs(cnt, s, now):
    if cnt == n:
        ans.append(s)
        return
    for i in range(now+1):
        dfs(cnt+1, s+al[i], max(i+1, now))

n = int(input())
ans = []
al = [chr(i) for i in range(97, 97+26)]
dfs(0, "", 0)
for i in ans:
    print(i)
n = int(input())

al = ['a','b','c','d','e','f','g','h','i','j']
w = ['a']

for num in range(n-1):
    x = []
    for i in range(len(w)):
        x.append(w[i] + 'a')
        for num in range(num+1):
            if al[num] in w[i]:
                x.append(w[i] + al[num+1])
    w = x

for _ in range(len(w)):
    print(w[_])
from collections import deque
n=int(input())
ans=deque(['a'])
while True:
  a=ans.popleft()
  if len(a)==n:
    ans.appendleft(a)
    break
  m=max(a)
  for i in range(ord(m)-96+1):
    ans.append(a+chr(97+i))
print(*ans,sep='\n')
N = int(input())
def dfs(s):
  if len(s) == N:
    print(s)
    return
  for i in range(ord("a"), ord("z")+1):
    dfs(s+chr(i))
    if max(list(s)) == chr(i-1):
      return
dfs("a")
n=int(input())
ans=[]

def dfs(i,c,d):
	if i==n:
		ans.append(c)
		return
	for j in range(0,d+1):
		dfs(i+1,c+chr(97+j),d+(j==d))

dfs(0,"",0)

print("\n".join(ans))
N = int(input())
ans = ['a']
moji = ['a','b','c','d','e','f','g','h','i','j']
count = 1
while count < N:
    tmp = []
    for i in ans:
        for k in range(len(set(list(i)))+1):
            tmp.append(i+moji[k])
    count += 1
    ans = tmp
ans.sort()
for i in ans:
    print(i)
N = int(input())
s = 'a'
ans = []
alpha = [chr(ord('a') + j) for j in range(10)]
#print(alpha)
def dfs(S):
  if len(S)==N:
    ans.append(S)
    #print(S)
    return None
  lis = alpha[:max([alpha.index(s) for s in S])+2]
  #print(lis)
  for t in lis:
    T = S+t
    dfs(T)
    
dfs('a')
print(*ans, sep='\n')
n=int(input())
def dsf(s,k):
    if len(s)==n:
        print(s)
    else:
        for i in range(k):
            dsf(s+chr(i+97),k)
        dsf(s+chr(k+97),k+1)
dsf("",0)
n = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
a = []
def h(i, s, t):
	if i == 0:
		a.append(s)
		print(s)
	else:
		for j in range(t+1):
			ns = s+l[j]
			nt = max([j+1, t])
			h(i-1, ns, nt)
h(n, "", 0)
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        for i in range(ord("a"), ord(mx) + 2):
            tmp = s
            tmp += chr(i)
            dfs(tmp, max(mx, chr(i)))

dfs("a", "a")
from collections import deque
N = int(input())
alpha = ['a','b','c','d','e','f','g','h','i','j']
ans = []

stack = deque(['a'])

while stack:
    if len(stack[-1]) == N:
        break
    s = stack.pop()
    s_list = sorted(list(s))
    index = alpha.index(s_list[-1])
    for i in range(index+2):
        stack.appendleft(s+alpha[i])
    

stack.reverse()
for j in range(len(stack)):
    print(stack[j])
import string
def dfs(w, d):
    if len(w) == N:
        print(w)
        return
    for i in range(d + 1):
        if i == d:
            dfs(w + wordlst[i], d + 1)
        else:
            dfs(w + wordlst[i], d)

N = int(input())
anslst = []
nlst = [0] * N
wordlst = string.ascii_lowercase
dfs('a', 1)
def main():
    from string import ascii_lowercase
    dic = {i: s for i, s in enumerate(ascii_lowercase)}
    N = int(input())
    ans = []

    def dfs(s, mx):
        if len(s) == N:
            ans.append(s)
            return
        else:
            for i in range(mx+2):
                mx = max(mx, i)
                dfs(s + dic[i], mx)
    dfs("a", 0)
    print(*ans, sep="\n")


if __name__ == '__main__':
    main()
n = int(input())
alpha = "abcdefghij"
lst = []
def f(s,k):
    if len(s) == n:
        print(s) 
        return
    for i in range(k+1):
        if i == k: f(s+alpha[i],k+1)
        else: f(s+alpha[i],k)
f("",0)
abc = "abcdefghij"

N = int(input())

def dfs(S, i):
    if len(S) == N:
        return S + "\n"

    res = ""
    for c in abc[:i]:
        res += dfs(S + c, i)
    res += dfs(S + abc[i], i + 1)

    return res

print(dfs("", 0))
n = int(input())
s = [('', 0)]
cnt = 0
ans = []
while s:
    t, k = s.pop()
    if len(t) == n:
        ans.append(t)
    else:
        s.append((t + chr(k + 97), k + 1))
        for i in range(k - 1, -1, -1):
            s.append((t + chr(i + 97), k))
ans.sort()
for row in ans:
    print(row)
n = int(input())
l = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]
def dfs(res, i):
    if len(res) >= n:
        print(res)
        return
    for k in range(i):
        dfs(res+l[k], i)
    dfs(res+l[i], i+1)
dfs("", 0)
# coding: utf-8
# Your code here!
N=int(input())

cand=["a"]

num=98
for i in range(N-1):
    #print(i)
    temp=[]
    for item in cand:
        ma=0
        for c in item:
            ma=max(ma,ord(c))
        for i in range(ma-95):
            temp.append(item+chr(i+97))
    num+=1
    cand=temp[:]

for item in cand:
    print(item)
def main():
    from string import ascii_lowercase

    N = int(input())

    ans = []

    def dfs(s='a', ma='a'):
        if len(s) == N:
            ans.append(s)
            return

        for c in ascii_lowercase:
            dfs(s + c, max(c, ma))
            if c > ma: break

    dfs()

    print(*ans, sep='\n')


if __name__ == '__main__':
    main()
from itertools import combinations_with_replacement
from itertools import combinations
N = int(input())

alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]
cand = {"a"}
for i in range(N-1):
    nex_cand = set()
    for c in cand:
        for j in range(i+2):
            a = alpha[j]
            if all(v in c for v in alpha[:j]):
                nex_cand.add(c+a)
    cand = nex_cand

print("\n".join(sorted(cand)))
n = int(input())
A= 'a'
# 文字数を増やして, その各々の元に対して文字を追加する.
for _ in range(n - 1):
    A = {a + s for a in A for s in a + chr(ord(max(a)) + 1)}
    # print(A)
# 最後にsortして調整する.
#print(*A, sep = '\n')
print(*sorted(A), sep='\n')
# import bisect
# # import heapq
# # from copy import deepcopy
# # from collections import deque
# # from collections import Counter
# # from itertools import accumulate
# # from itertools import permutations
# import numpy as np
# # import math
# a,b,c = map(int, input().split())
n = int(input())
# p = list(map(int, input().split()))


def dfs(s, var):
    if len(s) == n:
        print(s)
    else:
        for i in range(var):
            dfs(s+chr(ord('a')+i), var)

        dfs(s+chr(ord('a')+var), var+1)

dfs('a',1)
import sys
sys.setrecursionlimit(100000000)
def dfs(s,n,m,subs):
  if len(subs)==n:
    print(subs)
    return
  
  k = len(set(list(subs)))+1

  for i in range(k):
    t = "".join((subs,s[i]))
    dfs(s,n,k,t)

s = "abcdefghij"

n = int(input())
s = list(s[:n])
dfs(s,n,1,"a")
from collections import deque
n = int(input())
abc = 'abcdefghij'
s = ''
cnt = 0
ans = deque([s])
while True:
    a = ans.popleft()
    cnt = len(a)
    if cnt == n:
        ans.append(a)
        break
    kind = len(set(a)) + 1
    for i in range(kind):
        ans.append(a + abc[i])

for i in sorted(ans):
    print(i)
n = int(input())
L = []
def f(s, m):
    if len(s) == n:
        L.append(s)
        return
    for i in range(97, m+2):
        f(s + chr(i), max(i, m))
f("a", 97)
for l in L:
    print(l)
n=int(input())
char=[chr(i) for i in range(97, 97+26)]

ans=["a"]
before=0

for i in range(2,n+1):
    for c in range(len(ans)):
        From=char.index(sorted(list(ans[c]))[-1])
        for m in range(From+2):
            ans.append(ans[c]+char[m])
    #print(ans)
    
b=[]

for g in range(len(ans)):
    if len(ans[g])==n:
        b.append(ans[g])

b.sort()

for i in range(len(b)):
    print(b[i])
N = int(input())

S = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"]

def dfs(s, i):
    if len(s) == N:
        return [s]
    result = []
    for j in range(i+1):
        if j == i:
            result += dfs(s+S[j], i+1)
        else:
            result += dfs(s+S[j], i)
    return result
print("\n".join(dfs("", 0)))
N = int(input())

def f(s, mx):
    if len(s) == N:
        print(s)
        return
    for i in range(mx+1):
        f(s + chr(ord("a") + i), max(mx, i+1))

f("", 0)
N=int(input())
def f(l,m,n):
    if n==N:
        print(''.join([chr(ord('a')+i) for i in l]))
    else:
        for i in range(m+2):
            f(l+[i],max(m,i),n+1)
f([0],0,1)
N=int(input())
ABC=["a","b","c","d","e","f","g","h","i","j"]
def dfs(n,s):
  if len(s)==N:
    print(s)
    return
  
  for i in range(n+1):
    _s=s+ABC[i]
    dfs(max(n,i+1),_s)
    
dfs(0,"")
N = int(input())

# mx = count up flag
def dfs(s, mx):
    if len(s) == N:
        print(s)
    else:
        for c in range(ord('a'), mx+1):
            dfs(s+chr(c), mx + 1 if c == mx else mx)

dfs("", ord('a'))
n = int(input())

d = 'abcdefghijklm'


def conv(s):
    s = list(map(lambda x: d[x], s))
    return ''.join(s)


def dfs(s):
    if len(s) == n:
        print(conv(s))
    else:
        mx = max(s)+1
        for i in range(mx+1):
            dfs(s+[i])


dfs([0])
N = int(input())
al = [chr(i + 97) for i in range(N)]
def sol(S):
    if len(S) == N:
        print(S)
        return
    for i in range(len(set(S)) + 1):
        sol(S + al[i])
sol('')
N = int(input())

s = []

A = "abcdefghijklmnopqrstuvwxyz"

def ss(n):
    if n == 1:
        return [[0]]
    tt = ss(n-1)
    res = []
    for t in tt:
        m = max(t)
        for i in range(m + 2):
            res.append(t + [i])
    return res

for s in ss(N):
    S = ''.join([A[i] for i in s])
    print(S)
#!/usr/bin python3
# -*- coding: utf-8 -*-

def stds(n):
    if n == 1:
        return set(['a'])
    else:
        std = stds(n-1)
        ret = set([])
        for stdi in std:
            for x in range(ord('a'),max(map(ord,list(stdi))) + 2):
                ret.add(stdi + chr(x))
        return ret

def main():
    N = int(input())
    ret = list(stds(N))
    ret.sort()
    print('\n'.join(ret))


if __name__ == '__main__':
    main()