peterverebics/CodeNet_Python_118 huggingface dataset:
import sys

N=int(input())
if N==1:
  print("a")
  sys.exit()
  
old_list=[[0]]
for i in range(1,N):
  new_list=[]
  for l in old_list:
    tail=l[-1]
    for k in range(tail+2):
      new_list.append(l+[k])
  old_list=new_list
    
#print(old_list)
llist=["a","b","c","d","e","f","g","h","i","j"]

for ll in old_list:
  #print(ll)
  str_list=[]
  for elm in ll:
    str_list.append(llist[elm])
  print("".join(str_list))
n=int(input())
def dfs():
  todo=[[1]]
  ret=[]
  while len(todo)>0:
    t=todo.pop()
    if len(t)==n:
      ret.append(t)
    else:
      t.append(t[-1])
      tc=t.copy()
      tc[-1]+=1
      todo.append(tc)
      todo.append(t)
  return ret
a=dfs()
n2a = lambda c: chr(c+64).lower()
for ai in a:
  #print(ai)
  print(''.join(map(n2a,ai)))
import sys
sys.setrecursionlimit(10**7)
alpha = "abcdefghijklmnopqrstuvwxyz"
ans = []
n = int(input())
def saiki(s):
    global ans
    if len(s) == n:
        ans.append(s)
    else:
        i = alpha.index(s[-1])
        for j in range(i+2):
            saiki(s+alpha[j])
saiki("a")
print("\n".join(ans))
n=int(input())
tmp=[['1',set({1})]]
for i in range(1,n):
  tmp2=[]
  for s,c in tmp:
    for j in range(len(c)+1):
      tmp2.append([s+str((j+1)%10),c|set({j+1})])
  tmp=tmp2
ans=[]
dic={'1':'a','2':'b','3':'c','4':'d','5':'e','6':'f','7':'g','8':'h','9':'i','0':'k'}
for s,c in tmp:
  ts=''
  for tc in s:
    ts+=dic[tc]
  ans.append(ts)
ans=sorted(ans)
for s in ans:
  print(s)
import itertools
from sys import exit

N = int(input())

seq = 'abcdefghij'
print('a' * N)
if N == 1:
    exit()

print('a' * (N - 1) + 'b')
if N == 2:
    exit()

for i in range(1, N - 1):
    lst = ['a'] * (N - i - 1) + ['b']
    it = itertools.product(seq[:i + 1], repeat=i)
    while True:
        try:
            print(''.join(map(str, lst + list(next(it)))))
        except StopIteration:
            break
    print(''.join(map(str, lst)) + seq[2:i+2])
import sys
from itertools import product

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    def dfs(s, num):
        if len(s) == n:
            print(s)
            return

        for i in range(num + 1):
            t = s + chr(97 + i)
            dfs(t, i + 1)

    dfs("", 0)


if __name__ == '__main__':
    resolve()
import sys
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)
  
N = int(input())
#print(N)
if N == 1:
  print(1)
  sys.exit()
elif N == 2:
  print(2)
  sys.exit()

r = N - 2

ret = permutations_count(N, r) + 2
print(ret)
n=int(input())
x=["a"]*n
print("".join(x))
for i in range(n-1):
    xx=x[:] 
    xx[n-i-1]="b" 
    print("".join(xx))
if n>2:
    print("a"+"b"*(n-1))
from itertools import product
n=int(input())
s='abcdefghijklmnopqrstuvwxyz'
use_s=tuple(s[:n])
#print(use_s,1)
for i in product(use_s, repeat=n):
    ans=i
    if tuple(use_s)<ans:continue
    print(''.join(ans))
n = int(input())
if n == 1:
    print("a")
if n == 2:
    print("aa")
    print("ab")
elif n == 3:
    print("aaa")
    print("aab")
    print("aac")
    print("aba")
    print("abb")
    print("abc")
    print("acb")
elif n == 4:
    print("aaaa")
    print("aaab")
    print("aabb")
    print("abbb")
else:
    print("hoge")
n = int(input())
al_list = ["a","b","c","d","e","f","g","h","i","j","k","l"]
def dfs(s,final,al_list):
  if len(s) == n:
    print(s)
  else:
    for hoge in range(al_list.index(final) + 2):
      tmp = s
      final = al_list[hoge]
      tmp += final
      dfs(tmp,final,al_list)
dfs("a","a",al_list)
N = int(input())

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

for i in range(N - 1):
  w_init = w
  w = []
  for j in range(len(w_init)):
    for k in range(i + 2):
      if w_init[j][-1] == l[k]:
        for m in range(k + 2):
          w.append(w_init[j] + l[m])

for i in range(len(w)):
  print(w[i])
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
ans = []
a = ord('a')


def f(l, nmax, num):
    global N, a
    if l == N:
        ans.append(''.join(num))
    else:
        for i in range(nmax + 1):
            S = num + [chr(i + a)]
            f(l + 1, nmax + 1, S)


f(0, 0, [])

ans.sort()
print(*ans, sep='\n')
n = int(input())
alpha = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"]
def doukei(n):
  if n == 1:
    return ["a"]
  k = doukei(n-1)
  ans = []
  for i in range(len(k)):
    key = k[i][-1]
    ans.append(k[i]+"a")
    for j in range(1, 10):
      ans.append(k[i]+alpha[j])
      if key == alpha[j-1]:
        break
  return ans
answer = doukei(n)
for i in range(len(answer)):
  print(answer[i])
N = int(input())

def it(remain,n):
    if remain == 0:
        yield tuple()
    else:
        for d in it(remain-1,n):
            for x in range(n):
                yield (x,)+d
        for d in it(remain-1,n+1):
            yield (n,)+d


print(*(''.join(chr(x+ord('a')) for x in d) for d in it(N,0)), sep='\n')
N = int(input())
S = "abcdefghijklmn"
Q = [(1,"a")]
A = []
while Q:
    q = Q.pop(-1)
    if q[0]==N:
        A.append(q[1])
        continue
    for i in range(S.index(q[1][-1])+2):
        Q.append((q[0]+1,q[1]+S[i]))
for a in sorted(A):print(a)
def num_to_str(n):
    return chr(97 + n)

def str_to_num(s):
    return ord(s) - 97

def dfs(s,m,n,N,ans):
    if n == N:
        ans.append(s)
        return
    for i in range(m+2):
        dfs(s+num_to_str(i),max(m,i),n+1,N,ans)

def main():
    N = int(input())
    ans = []
    dfs('a',0,1,N,ans)
    ans.sort()
    print(ans)


if __name__ == "__main__":
    main()
n=int(input())
L=['a','b','c','d','e','f','g','h','i','j']
ans=['a']
for i in range(2,n+1):
    que=L[:i]
    temp2=[]
    for moji in que:
        temp=[]
        for a in ans:
            a=''.join([a,moji])
            temp.append(a)
        temp2+=temp
    ans=temp2
print(*ans, sep='\n')
def main():
    N = int(input())
    li = 'abcdefghijklmnopqrstuvwxyz'

    def f(k):
        nonlocal li
        if k == 1:
            return ['a']
        else:
            temp = f(k-1)
            return [t+char for t in temp for char in li[:k]]

    result = f(N)
    print(sorted(result))

if __name__ == '__main__':
    main()
n = str(input())
num2alpha = lambda c: chr(c+97)

def plus(string):
    tmp = []
    for i in range(0,min(int(n)+1,int(string[-1])+2)):
        tmp.append(string+str(i))
    return tmp

if n == "1":
    print(1)
else:
    ans = ["0"]
    for i in range(int(n)-1):
        for j,a in enumerate(ans):
            ans[j] = plus(a)
        ans = sum(ans,[])
    for i in ans:
        for j in list(i):
            print(num2alpha(int(j)),end="")
        print()
n=int(input())
ans1=""
ans2=""

for i in range(n):
    ans1=ans1+"a"

for j in range(97,n+97):
    ans2=ans2+chr(j)

print(ans1)
print(ans2)
N = int(input())
# alpha = [chr(ord("a")+i) for i in range(10)]
ans = [[] for _ in range(N)]
ans[0].append("a")
for i in range(N-1):
    for e in ans[i]:
        idx = ord(e[-1]) - ord("a")
        for j in range(idx+2):
            ans[i+1].append(e+chr(ord("a")+j))
for e1 in ans:
    for e2 in e1:
        print(e2)
n = int(input())
words = ['a', 'b', 'c', 'd', 'e', 'f','g','h', 'i', 'j']
ans = [[] for _ in range(n)]
ans[0].append("a")
for i in range(n - 1):
    for ai in ans[i]:
        for j in range(i + 2):
            ans[i + 1].append(ai + words[j])
# print(ans[n - 1])
for a in ans[n - 1]:
    print(a)
s = 'abcdefghij'
sg = s.__getitem__


def dfs(ans):
    if len(ans) == n:
        print(''.join(map(sg, ans)))
        return
    for i in range(ans[-1] + 2):
        ans.append(i)
        dfs(ans)
        ans.pop()


n = int(input())
dfs([0])
n = int(input())
s = "bcdefghijk"
if n == 1:
    print("a")
elif n == 2:
    print("aa")
    print("ab")
elif n >= 3:
    prefix = "a"*(n-1)
    for _ in range(n):
        print("{}{}".format(prefix,s[n-1]))
import math
a = int(input())
b = 'abcdefghij'

for i in range(a):
  if i < a - 1:
    print(b[0:i]+b[i]*(a-i))
  else:
    print(b[0:i+1])
n=int(input())

A=["aa","ab"]
num2alpha = lambda c: chr(c+64)
B=[]
num2alpha(3)
if n==1:
	print("a")
	exit()
if n==2:
	print("aa")
	print("ab")

for i in range(n-2):
	k=i+3
	for s in A:
		B.append(s+"a")
		B.append(s+"b")
		if s[-1]!= "a":
			B.append(s+chr(ord(s[-1])+1))
	A=A+B
	B=[]
for x in A:
	if len(x)==n:
		print(x)
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:
        c = b[-1]
        x = ord(c)
        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)
n = int(input())

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

def dfs(x,alp):
    if x == n-1:
        print(''.join(s))
        return
    
    for i in range(alp+2):
        #print(x+1)
        s[x+1] = chr(i+65+32)
        dfs(x+1,alp+1)



dfs(0,0)
d = ['a','b','c','d','e','f','g','h','i','j']

n = int(input())

result = []

def fig(v, num):
    if v == n:
        result.append(num)
        return
    
    for i in range(v+1):
        fig(v+1, num + d[i])

fig(0, '')
result.sort()
for r in result:
    print(r)
n = int(input())

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

def dfs(x,alp):
    if x == n-1:
        print(''.join(s))
        return
    
    for i in range(alp+2):
        #print(x,alp)
        s[x+1] = chr(i+65+32)
        dfs(x+1,min(alp+i,alp+1))
        #print(alp)


dfs(0,0)
n=int(input())

def saiki(l,n):
  tmp=[]
  for limit,s in enumerate(l):
    for i in range(n):
      if i>=limit+2: break
      tmp.append(s+chr(ord('a')+i))
  return tmp

ans=['a']
for i in range(1,n):
  ans=saiki(ans,i+1)
print(*ans,sep='\n')
import sys
import math
import string
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()
alphabets = string.ascii_lowercase

N = int(input())
ans = [["a", 0]]
for i in range(N - 1):
    ans2 = copy.deepcopy(ans)
    ans = []
    for l in ans2:
        for k in range(min(l[1] + 2, i + 2)):
            ans.append([l[0] + alphabets[k], k])
for i in ans:
    print(i[0])
# -*- coding: utf-8 -*-

alphabets = list('abcdefghijklmnopqrstuvwxyz')

N = int(input())

if N == 1:
    print('a')
else:
    str_tmp = ['a']
    str_final = []
    for i in range(1, N):
        for s in str_tmp:
            for alphabet in set(list(s)):
                str_final.append(s+alphabet)
            str_final.append(s+alphabets[len(set(list(s)))])
    print(str_final)
n = int(input())
ls = []
alphabet = [chr(i) for i in range(97, 97+26)]
alphabet_dict = {}
for i, a in enumerate(alphabet):
    alphabet_dict[a] = i
def dfs(A):
    if len(A) == n:
        ls.append(A)
        return
    l = alphabet_dict[A[-1]]
    for i in range(l+2):
        A += alphabet[i]
        dfs(A)
        A = A[:-1]
dfs('a')
ls.sort()
for i in range(len(ls)):
    print(ls[i])
from string import ascii_lowercase as alph

def gen_pattern(N, pre=""):
  for c in alph[:ord(max(pre or "\x60"))-0x5f]:
    pattern = pre+c
    if len(pattern) == N:
      yield pattern
    else:
      yield from gen_pattern(N, pattern)

for pattern in gen_pattern(3):
  print(pattern)
numal=lambda c:chr(c+97)
n=int(input())
unchi=[[],[],[],[],[],[],[],[],[],[]]
unchi[0].append("0")
k=1
if n>=2:
	while k<n:
		for i in range(len(unchi[k-1])):
			for u in range(int(unchi[k-1][i][k-1])+2):
				unchi[k].append(unchi[k-1][i]+str(u))
		k+=1
for i in range(len(unchi[n-1])):
	s = []
	for k in range(n):
		s.append(numal(int(unchi[n-1][i][k])))
	print("".join(s))
from itertools import product
from collections import deque

N = int(input())
d = deque(["b","c","d","e","f","g","h","i","j","k"])
l = ["a", "x"]

for s in list(product(l,repeat=N-1)):
  tmp = list(s)
  for i in range(len(tmp)):
    if tmp[i] == "x":
      tmp[i] = d.popleft()
  print("a"+"".join(tmp))
  d = deque(["b","c","d","e","f","g","h","i","j","k"])
def create_li(li):
  if len(li) >= n:
    lis.append(li)
    return
  p = li[-1]
  ret = []
  for i in range(1, p + 2):
    cp = li[:]
    cp.append(i)
 #   print(cp)
    create_li(cp)

lis = []
  
n = int(input())
pre = [1]
create_li(pre)
lis.sort()
al = ["a","b","c","d","e","f","g","h","i","j"]
ans = set(["".join([al[id-1] for id in i]) for i in lis])
ans = list(ans)
ans.sort()
for i in ans:
  print(i)
from collections import deque
n = int(input())
l = ["a","b","c","d","e","f","g","h","i","j","k"]
ansl = []
d = deque()
ans = "a"
d.append([ans,0])
while len(d):
    now,m = d.pop()
    if len(now) == n:
        ansl.append(now)
    else:
        d.append([now+l[m],m])
        d.append([now+l[m+1],m+1])
        if m > 0:
            d.append([now+l[0],0])
ansl.sort()
for i in ansl:
    print(i)
N = int(input())

tarans = {'1':'a','2':'b','3':'c','4':'d','5':'e','6':'f','7':'g','8':'h','9':'i'}
ans = ['1']

for i in range(2,N+1):
    temp = []

    for num in ans:
        for k in range(2):
            s = '1'
            for j in range(len(num)):
                s = s + str(int(num[j])+k)
            temp.append(s)
    ans = temp

ans.sort()

for s in ans:
    print(s.replace("10",'j').translate(str.maketrans(tarans)))
import itertools

n = int(input())
l = ['a', 'b', 'c', 'd','e','f','g','h','i','j']

if n == 1:
    print("a")

if n == 2:
    print("aa")
    print("ab")
    
if n >= 3:
    for v in itertools.product(l[:n - 1], repeat = n-1):
        if v[0] != l[n -2]:
            print("a" + "".join(v))
        else:
            break
    print("".join(l[:n]))
N = int(input())
alphabets = list('Zabcdefghijklmn')
s = ['a']
for i in range(2, N + 1):
    subset = alphabets[1:i + 1]
    # s = [s[j] + k for k in subset for j in range(len(s))]
    s = [s[j] + k for j in range(len(s)) for k in subset]

sorted_s = sorted(s)
# for i, j in zip(s, sorted_s):
# print(i, j, i == j)
print(*sorted_s, sep='\n')
L = []
def f(sa, n, b):
    # sa='a', n=9, b='b'
#    print(sa, n, b)
    if n == 0:
        L.append(sa)
        return
    for i in range(n, 0, -1):
        x = sa + b*i
        c = chr(ord(b) + 1)
        f(x, n-i, c)
i = f('', 10, 'a')
for l in L:
    print(l)
from operator import itemgetter
a = ("a", "b", "c", "d", "e")
N = int(input())
L = [0]*N

alpha=list('abcdefghijk')
print('a'*N)
for i in range(N,0,-1):
    for j in range(1,i,1):
        L[-j]+=1
        print(''.join([alpha[i] for i in L]))
from collections import deque
D1 = {i:chr(i+96) for i in range(1,27)}
D2 = {val:key for key,val in D1.items()}

N = int(input())
heap = deque([(D1[1],1)])
A = []
while heap:
    a,n = heap.popleft()
    if n<N:
        j = D2[a[-1]]
        for i in range(1,min(j+1,26)+1):
            heap.append((a+D1[i],n+1))
    if n==N:
        A.append(a)
A = sorted(A)
for i in range(len(A)):
    print(A[i])
n = int(input())
#lis = ['a',b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
ans = []
#for i in range(n):
t = ['a'] * n

ans.append(''.join(t))
for j in range(1,n):
    t = ['a'] * n
    t[j] = 'b'
    ans.append(''.join(t))
ans.sort()
for i in range(len(ans)):
    print(ans[i])
import sys
sys.setrecursionlimit(10000)
words = set()
alphabet = [chr(i) for i in range(97, 97+26)]
def add(s,j):
    if len(s) == n:
        words.add(s)
    else:
        s += j
        for i in alphabet:
            add(s,i)
n = int(input())
for i in alphabet:
    add("",i)
words = list(words)
words.sort()
#print(words)
words = words[0:n]
#print(words)
for word in words:
    print(word)
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
DP = [[] for i in range(10)]
DP[0] = ['a']
for i in range(9):
    for w in DP[i]:
        num = alpha.index(w[-1])
        for j in range(num+1):
            DP[i+1].append(w + alpha[j])
        if num + 1 <= 9:
            DP[i+1].append(w + alpha[num+1])
N  = int(input())
for w in DP[N-1]:
    print(w)
N = int(input())
alp = [chr(i) for i in range(97, 97+26)]
for i in range(N):
    if i!=0:
        start = int('1'+'0'*(i-1))
        end = int(''.join([str(j) for j in range(1,i+1)]))
        for m in range(start, end+1):
            ids = [0]*(N-i)
            ids.extend([int(o) for o in str(m)])
            print(''.join([alp[one] for one in ids]))
    else:
        print('a'*N)
n = int(input())
L = []
def f(s):
    if len(s) == n:
        L.append(s)
        return
    for i in range(97, ord(s[-1])+2):
        f(s + chr(i))
f("a")
for l in L:
    print(l)
# Code for D - String Equivalence
# Use input() to fetch data from STDIN
n = int(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

def d(x):
    return a[:x+1]

def s(level, count):
    if level == 1:
        return d(count)

    array = []
    for z in range(count+1):
        array.extend([a[z] + y for y in s(level - 1, z + 1)])
    return array

result = s(n, 0)
result.sort()
for x in result:
    print(x)
al=[chr(ord('a') + i) for i in range(26)]
N=int(input())
ans=[[] for _ in range(N)]
ans[0].append("a")

if N==1:
  print("a")
else:
  for i in range(1,N):    
    for item in ans[i-1]:
      for j in range(i+1):
        ans[i].append(item +chr(ord('a') + j))
  for answer in ans[-1]:
    print(answer)
n = int(input())
a = [ [] for _ in range(11) ]
a[0].append("a")

alp = "abcdefghijklmn"
for i in range(1, 10):
    for aa in a[i-1]:
        for c in alp[:i+1]:
            a[i].append(aa+c)

for ans in a[n-1]:
    print(ans)
n = int(input())
al = ['a','b','c','d','e','f','g','h','i','j']

dpn = ['']
dpp = ['']*1
l = 1
for i in range(n):
    for j in range(len(dpn)):
        for k in range(i+1):
            if i <= n:
                dpp[j*(i+1)+k] = dpn[j] + al[k]
            else:
                print(dpn[j] + al[k])
    dpn = dpp
    l *= i+2
    dpp = ['']*l
import string
n = int(input())
cs = string.ascii_lowercase
cm = {cs[i]:i for i in range(len(cs))}

def rec(st):
    if (len(st) >= n):
        print(st)
        return 0
    k = max(cm[st[i]] for i in range(len(st)))
    if (k == cm[st[-1]]):
        k += 1
    for c in cs[: k + 1]:
        rec(st+c)
    
    
rec('a')
N = int(input())

pre = ["a"]
for n in range(N - 1):
    nex = []
    for v in pre:
        for i in range(ord("a"), ord(v[-1]) + 2):
            nex.append(v + chr(i))
    pre = nex[:]
        
print(*sorted(pre), sep="\n")
import sys 
sys.setrecursionlimit(4100000)

N = int(input())

def dfs(i,s,ord_num):
    if i == N:
        
        return print(s)
    
    if dfs(i+1,s + "a",ord_num):
        
        return True
    
    if dfs(i+1,s + chr(ord_num + 1),ord_num + 1):
        
        return True
    
    return False
    
dfs(1,"a",ord("a"))
import string

alphabet = string.ascii_lowercase

n = int(input())

def DFS(before,keta):
    num = 0
    if keta == n:
        print(before)
        return
    for i in before:
        num = min(num,alphabet.index(i))+1
        
    for j in range(num+1):
        DFS(before+alphabet[j],keta+1)

DFS("",0)
n = int(input())

alf = 'abcdefghijk'

ans = 'a'
index = 0

for _ in range(n):
    temp = ans
    temp = temp + alf[index]
    print(temp)
    index += 1
N = int(input())
 
def func(n):
  if n <= 1:
    return ["a"]
  S = []
  for i in func(n - 1):
    S.append("a" + i)
    S.append("a" + i.replace("a","x").replace("b","a").replace("x","b"))
    
  return S
 
Ans = func(N)

Ans = list(set(Ans))
Ans.sort()
for i in Ans:
  print(i)
n = int(input())
c = "a"*n
print(c)
c = list(c)
if n > 1:
    p = n
    for j in range(n):
        for i in range(p-1):
            c[-(i+1)] = chr(ord("a") + (j+1))
            print(''.join(c))
        p -= 1
n = int(input())
ans = ["a"]

for i in range(0,len(ans)):
  while len(ans[i]) < n:
    k = ord(ans[i][-1])
    for j in range(97,k+2):
      ans.append(ans[i] + chr(j))
    del ans[i]

sorted(ans)
for i in range(0,len(ans)):
  print(ans[i])
import sys
sys.setrecursionlimit(10**7)
n = int(input())
ls = []


def dfs(s):
    if len(s) == n:
        ls.append(s)
        return 0
    else:
        for x in map(chr, range(97, ord(s[-1])+2)):
            dfs(s+x)


dfs("a")
ls.sort()
for x in ls:
    print(x)
from time import time 

n=int(input())
from itertools import combinations as pe
al=[]
for i in range(n):
    for tu in pe(range(n-1),i):
        if tu:
            pre=tu[0]
            ans="a"*(pre+1)
            for d,v in enumerate(tu[1:]):
                ans+=chr(98+d)*(v-pre);pre=v
            ans+=chr(ord(ans[-1])+1)*(n-len(ans))
            al.append(ans)
        else:print("a"*n)
print(*sorted(al),sep="\n")
N = int(input())
def f(n,s):
    if n == 0:
        print(s)
        return
    for i in [chr(ord("a") + i) for i in range(N-n+1)]:
        if s != "" and ord(i) - ord(s[-1]) > 1:
            return 
        f(n-1,s+i)
f(N,"")
n = int(input())
c = list(map(chr, range(97, 97+26)))
for i in range(1, n+1):
    s = ""
    s += "a"*(n-i)
    s += "".join(c[0:i])
    print(s)
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque, Counter
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

def res(n, cur, ln, k):
    if ln == n:
        print(cur)
        return
    for i in range(k+2):
        res(n, cur + chr(ord("a") + i), ln+1, i)
    # res(n, cur + chr(ord("a") + k+1), ln + 1, k+1)


def main():
    n = getN()
    res(n, "a", 1, 0)
if __name__ == "__main__":
    main()
n = int(input())
res = [-1] * n
def do(a, b):
    #print("do",a,b)
    if a >= n:
        return
    res[a] = b
    if a == n - 1:
        print("".join(list(map(lambda x: chr(ord("a") - 1 + x), res))))
        return
    for i in range(1, b + 2):
        do(a + 1, i)

do(0, 1)
n = int(input())

alp = [chr(v) for v in range(ord("a"), ord("z") + 1)]

def bitcount(v):
    cnt = 0
    for i in range(n + 1):
        cnt += bool(v & (1 << i))
    return cnt

results = []
def f(i=0, j=0, s="", state=0):
    if i == n:
        if bitcount(state + 1) == 1:
            results.append(s)
        return
    for j in range(i + 1):
        f(i + 1, j, s + alp[j], state | (1 << j))
f()
print(*results, sep="\n")
n = int(input())

def dfs(s):
  if len(s) == n:
    print(s)
  else:
    for i in range(ord(s[len(s) - 1]) - ord('a') + 1):
      s += chr(i + ord('a'))
      dfs(s)
      
s = 'a'
dfs(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[s[-1]]
    for i in S[:idx+2]:
        main(s+i, n+1)
        
main('a', 1)
N = int(input())

a_num = 97

def dfs(s, n, cnt): 
    if n == 0:
        print(s)
        return
    for i in range(cnt+2):
        dfs(s+chr(a_num+i), n-1, cnt+i)

dfs("a", N-1, 0)
import string

alphabet = string.ascii_lowercase

n = int(input())

def DFS(before,keta):
    num = 0
    if keta == n:
        print(before)
        return
    for i in before:
        num = max(num,alphabet.index(i))+1
    for j in range(num+1):
        DFS(before+alphabet[j],keta+1)
DFS("",0)
def d_string_equivalence():
    from itertools import product
    N = int(input())

    ans = ['a' + ''.join(s) for s in product('ab', repeat=N - 1)]
    return '\n'.join(ans)

print(d_string_equivalence())
N = int(input())
ans = []
def dfs(s):
    if(len(s) == N):
        ans.append(s)
        return
    else:
        next_str = chr(ord(s[-1]) + 1)
        pre_str = chr(ord(s[-1]) - 1)
        dfs(s + s[-1])
        dfs(s + next_str)
        if(s[-1] != "a"):
            dfs(s + pre_str)

dfs("a")

ans = sorted(ans)
for a in ans:
    print(a)
n = int( input() )

for i in range(n):
  print("a"*(n -i),"b"*i,sep='')
def sol(k):

    def gen(d, cur, s):
        if d == k:
            yield s
            return
        for i in range(0, cur+1):
            yield from gen(d+1, i+1, s+chr(97+i))

    return gen(0, 0, '')

def main():
    k = int(input())
    for x in sol(k):
        print(x)

if __name__ == '__main__':
    main()
def dfs(out, ln, n):
    if len(out) == n:
        print(out)
    else:
        for i in range(ln, n):
            l = chr(ord('a') + i)
            dfs(out+l, i, n)

n = int(input())
dfs('a', 0, n)
n = int(input())

d = 'abcdefghijklm'


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


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


dfs('a', 1)