Problem:


Score : 400 points

Problem Statement

In this problem, we only consider strings consisting of lowercase English letters.

Strings s and t are said to be isomorphic when the following conditions are satisfied:

|s| = |t| holds.

For every pair i, j, one of the following holds:

s_i = s_j and t_i = t_j.

s_i \neq s_j and t_i \neq t_j.

For example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.

A string s is said to be in normal form when the following condition is satisfied:

For every string t that is isomorphic to s, s \leq t holds. Here \leq denotes lexicographic comparison.

For example, abcac is in normal form, but zyxzx is not since it is isomorphic to abcac, which is lexicographically smaller than zyxzx.

You are given an integer N.
Print all strings of length N that are in normal form, in lexicographically ascending order.

Constraints

1 \leq N \leq 10

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N

Output

Assume that there are K strings of length N that are in normal form: w_1, \ldots, w_K in lexicographical order.
Output should be in the following format:

w_1
:
w_K

Sample Input 1

1

Sample Output 1

a

Sample Input 2

2

Sample Output 2

aa
ab



Sample input:
1


Sample output:
a

Submission status: Wrong Answer

Solution code:
N = int(input())

if N == 1:
    print("a")
if N == 2:
    print("aa")
    print("ab")
if N == 3:
    print("aaa")
    print("aab")
    print("aba")
    print("abb")
if N == 4:
    print("aaaa")
    print("aaab")
    print("aaba")
    print("aabb")
    print("abaa")
    print("abab")
    print("abba")
    print("abbb")
if N == 5:
    print("aaaaa")
    print("aaaab")
    print("aaaba")
    print("aaabb")
    print("aabaa")
    print("aabab")
    print("aabba")
    print("aabbb")
    print("abaaa")
    print("abaab")
    print("ababa")
    print("ababb")
    print("abbaa")
    print("abbab")
    print("abbba")
    print("abbbb")
if N == 6:
    print("aaaaaa")
    print("aaaaab")
    print("aaaaba")
    print("aaaabb")
    print("aaabaa")
    print("aaabab")
    print("aaabba")
    print("aaabbb")
    print("aabaaa")
    print("aabaab")
    print("aababa")
    print("aababb")
    print("aabbaa")
    print("aabbab")
    print("aabbba")
    print("aabbbb")
    print("abaaaa")
    print("abaaab")
    print("abaaba")
    print("abaabb")
    print("ababaa")
    print("ababab")
    print("ababba")
    print("ababbb")
    print("abbaaa")
    print("abbaab")
    print("abbaba")
    print("abbabb")
    print("abbbaa")
    print("abbbab")
    print("abbbba")
    print("abbbbb")
if N == 7:
    print("aaaaaaa")
    print("aaaaaab")
    print("aaaaaba")
    print("aaaaabb")
    print("aaaabaa")
    print("aaaabab")
    print("aaaabba")
    print("aaaabbb")
    print("aaabaaa")
    print("aaabaab")
    print("aaababa")
    print("aaababb")
    print("aaabbaa")
    print("aaabbab")
    print("aaabbba")
    print("aaabbbb")
    print("aabaaaa")
    print("aabaaab")
    print("aabaaba")
    print("aabaabb")
    print("aababaa")
    print("aababab")
    print("aababba")
    print("aababbb")
    print("aabbaaa")
    print("aabbaab")
    print("aabbaba")
    print("aabbabb")
    print("aabbbaa")
    print("aabbbab")
    print("aabbbba")
    print("aabbbbb")
    print("abaaaaa")
    print("abaaaab")
    print("abaaaba")
    print("abaaabb")
    print("abaabaa")
    print("abaabab")
    print("abaabba")
    print("abaabbb")
    print("ababaaa")
    print("ababaab")
    print("abababa")
    print("abababb")
    print("ababbaa")
    print("ababbab")
    print("ababbba")
    print("ababbbb")
    print("abbaaaa")
    print("abbaaab")
    print("abbaaba")
    print("abbaabb")
    print("abbabaa")
    print("abbabab")
    print("abbabba")
    print("abbabbb")
    print("abbbaaa")
    print("abbbaab")
    print("abbbaba")
    print("abbbabb")
    print("abbbbaa")
    print("abbbbab")
    print("abbbbba")
    print("abbbbbb")
if N == 8:
    print("aaaaaaaa")
    print("aaaaaaab")
    print("aaaaaaba")
    print("aaaaaabb")
    print("aaaaabaa")
    print("aaaaabab")
    print("aaaaabba")
    print("aaaaabbb")
    print("aaaabaaa")
    print("aaaabaab")
    print("aaaababa")
    print("aaaababb")
    print("aaaabbaa")
    print("aaaabbab")
    print("aaaabbba")
    print("aaaabbbb")
    print("aaabaaaa")
    print("aaabaaab")
    print("aaabaaba")
    print("aaabaabb")
    print("aaababaa")
    print("aaababab")
    print("aaababba")
    print("aaababbb")
    print("aaabbaaa")
    print("aaabbaab")
    print("aaabbaba")
    print("aaabbabb")
    print("aaabbbaa")
    print("aaabbbab")
    print("aaabbbba")
    print("aaabbbbb")
    print("aabaaaaa")
    print("aabaaaab")
    print("aabaaaba")
    print("aabaaabb")
    print("aabaabaa")
    print("aabaabab")
    print("aabaabba")
    print("aabaabbb")
    print("aababaaa")
    print("aababaab")
    print("aabababa")
    print("aabababb")
    print("aababbaa")
    print("aababbab")
    print("aababbba")
    print("aababbbb")
    print("aabbaaaa")
    print("aabbaaab")
    print("aabbaaba")
    print("aabbaabb")
    print("aabbabaa")
    print("aabbabab")
    print("aabbabba")
    print("aabbabbb")
    print("aabbbaaa")
    print("aabbbaab")
    print("aabbbaba")
    print("aabbbabb")
    print("aabbbbaa")
    print("aabbbbab")
    print("aabbbbba")
    print("aabbbbbb")
    print("abaaaaaa")
    print("abaaaaab")
    print("abaaaaba")
    print("abaaaabb")
    print("abaaabaa")
    print("abaaabab")
    print("abaaabba")
    print("abaaabbb")
    print("abaabaaa")
    print("abaabaab")
    print("abaababa")
    print("abaababb")
    print("abaabbaa")
    print("abaabbab")
    print("abaabbba")
    print("abaabbbb")
    print("ababaaaa")
    print("ababaaab")
    print("ababaaba")
    print("ababaabb")
    print("abababaa")
    print("abababab")
    print("abababba")
    print("abababbb")
    print("ababbaaa")
    print("ababbaab")
    print("ababbaba")
    print("ababbabb")
    print("ababbbaa")
    print("ababbbab")
    print("ababbbba")
    print("ababbbbb")
    print("abbaaaaa")
    print("abbaaaab")
    print("abbaaaba")
    print("abbaaabb")
    print("abbaabaa")
    print("abbaabab")
    print("abbaabba")
    print("abbaabbb")
    print("abbabaaa")
    print("abbabaab")
    print("abbababa")
    print("abbababb")
    print("abbabbaa")
    print("abbabbab")
    print("abbabbba")
    print("abbabbbb")
    print("abbbaaaa")
    print("abbbaaab")
    print("abbbaaba")
    print("abbbaabb")
    print("abbbabaa")
    print("abbbabab")
    print("abbbabba")
    print("abbbabbb")
    print("abbbbaaa")
    print("abbbbaab")
    print("abbbbaba")
    print("abbbbabb")
    print("abbbbbaa")
    print("abbbbbab")
    print("abbbbbba")
    print("abbbbbbb")
if N == 9:
    print("aaaaaaaaa")
    print("aaaaaaaab")
    print("aaaaaaaba")
    print("aaaaaaabb")
    print("aaaaaabaa")
    print("aaaaaabab")
    print("aaaaaabba")
    print("aaaaaabbb")
    print("aaaaabaaa")
    print("aaaaabaab")
    print("aaaaababa")
    print("aaaaababb")
    print("aaaaabbaa")
    print("aaaaabbab")
    print("aaaaabbba")
    print("aaaaabbbb")
    print("aaaabaaaa")
    print("aaaabaaab")
    print("aaaabaaba")
    print("aaaabaabb")
    print("aaaababaa")
    print("aaaababab")
    print("aaaababba")
    print("aaaababbb")
    print("aaaabbaaa")
    print("aaaabbaab")
    print("aaaabbaba")
    print("aaaabbabb")
    print("aaaabbbaa")
    print("aaaabbbab")
    print("aaaabbbba")
    print("aaaabbbbb")
    print("aaabaaaaa")
    print("aaabaaaab")
    print("aaabaaaba")
    print("aaabaaabb")
    print("aaabaabaa")
    print("aaabaabab")
    print("aaabaabba")
    print("aaabaabbb")
    print("aaababaaa")
    print("aaababaab")
    print("aaabababa")
    print("aaabababb")
    print("aaababbaa")
    print("aaababbab")
    print("aaababbba")
    print("aaababbbb")
    print("aaabbaaaa")
    print("aaabbaaab")
    print("aaabbaaba")
    print("aaabbaabb")
    print("aaabbabaa")
    print("aaabbabab")
    print("aaabbabba")
    print("aaabbabbb")
    print("aaabbbaaa")
    print("aaabbbaab")
    print("aaabbbaba")
    print("aaabbbabb")
    print("aaabbbbaa")
    print("aaabbbbab")
    print("aaabbbbba")
    print("aaabbbbbb")
    print("aabaaaaaa")
    print("aabaaaaab")
    print("aabaaaaba")
    print("aabaaaabb")
    print("aabaaabaa")
    print("aabaaabab")
    print("aabaaabba")
    print("aabaaabbb")
    print("aabaabaaa")
    print("aabaabaab")
    print("aabaababa")
    print("aabaababb")
    print("aabaabbaa")
    print("aabaabbab")
    print("aabaabbba")
    print("aabaabbbb")
    print("aababaaaa")
    print("aababaaab")
    print("aababaaba")
    print("aababaabb")
    print("aabababaa")
    print("aabababab")
    print("aabababba")
    print("aabababbb")
    print("aababbaaa")
    print("aababbaab")
    print("aababbaba")
    print("aababbabb")
    print("aababbbaa")
    print("aababbbab")
    print("aababbbba")
    print("aababbbbb")
    print("aabbaaaaa")
    print("aabbaaaab")
    print("aabbaaaba")
    print("aabbaaabb")
    print("aabbaabaa")
    print("aabbaabab")
    print("aabbaabba")
    print("aabbaabbb")
    print("aabbabaaa")
    print("aabbabaab")
    print("aabbababa")
    print("aabbababb")
    print("aabbabbaa")
    print("aabbabbab")
    print("aabbabbba")
    print("aabbabbbb")
    print("aabbbaaaa")
    print("aabbbaaab")
    print("aabbbaaba")
    print("aabbbaabb")
    print("aabbbabaa")
    print("aabbbabab")
    print("aabbbabba")
    print("aabbbabbb")
    print("aabbbbaaa")
    print("aabbbbaab")
    print("aabbbbaba")
    print("aabbbbabb")
    print("aabbbbbaa")
    print("aabbbbbab")
    print("aabbbbbba")
    print("aabbbbbbb")
    print("abaaaaaaa")
    print("abaaaaaab")
    print("abaaaaaba")
    print("abaaaaabb")
    print("abaaaabaa")
    print("abaaaabab")
    print("abaaaabba")
    print("abaaaabbb")
    print("abaaabaaa")
    print("abaaabaab")
    print("abaaababa")
    print("abaaababb")
    print("abaaabbaa")
    print("abaaabbab")
    print("abaaabbba")
    print("abaaabbbb")
    print("abaabaaaa")
    print("abaabaaab")
    print("abaabaaba")
    print("abaabaabb")
    print("abaababaa")
    print("abaababab")
    print("abaababba")
    print("abaababbb")
    print("abaabbaaa")
    print("abaabbaab")
    print("abaabbaba")
    print("abaabbabb")
    print("abaabbbaa")
    print("abaabbbab")
    print("abaabbbba")
    print("abaabbbbb")
    print("ababaaaaa")
    print("ababaaaab")
    print("ababaaaba")
    print("ababaaabb")
    print("ababaabaa")
    print("ababaabab")
    print("ababaabba")
    print("ababaabbb")
    print("abababaaa")
    print("abababaab")
    print("ababababa")
    print("ababababb")
    print("abababbaa")
    print("abababbab")
    print("abababbba")
    print("abababbbb")
    print("ababbaaaa")
    print("ababbaaab")
    print("ababbaaba")
    print("ababbaabb")
    print("ababbabaa")
    print("ababbabab")
    print("ababbabba")
    print("ababbabbb")
    print("ababbbaaa")
    print("ababbbaab")
    print("ababbbaba")
    print("ababbbabb")
    print("ababbbbaa")
    print("ababbbbab")
    print("ababbbbba")
    print("ababbbbbb")
    print("abbaaaaaa")
    print("abbaaaaab")
    print("abbaaaaba")
    print("abbaaaabb")
    print("abbaaabaa")
    print("abbaaabab")
    print("abbaaabba")
    print("abbaaabbb")
    print("abbaabaaa")
    print("abbaabaab")
    print("abbaababa")
    print("abbaababb")
    print("abbaabbaa")
    print("abbaabbab")
    print("abbaabbba")
    print("abbaabbbb")
    print("abbabaaaa")
    print("abbabaaab")
    print("abbabaaba")
    print("abbabaabb")
    print("abbababaa")
    print("abbababab")
    print("abbababba")
    print("abbababbb")
    print("abbabbaaa")
    print("abbabbaab")
    print("abbabbaba")
    print("abbabbabb")
    print("abbabbbaa")
    print("abbabbbab")
    print("abbabbbba")
    print("abbabbbbb")
    print("abbbaaaaa")
    print("abbbaaaab")
    print("abbbaaaba")
    print("abbbaaabb")
    print("abbbaabaa")
    print("abbbaabab")
    print("abbbaabba")
    print("abbbaabbb")
    print("abbbabaaa")
    print("abbbabaab")
    print("abbbababa")
    print("abbbababb")
    print("abbbabbaa")
    print("abbbabbab")
    print("abbbabbba")
    print("abbbabbbb")
    print("abbbbaaaa")
    print("abbbbaaab")
    print("abbbbaaba")
    print("abbbbaabb")
    print("abbbbabaa")
    print("abbbbabab")
    print("abbbbabba")
    print("abbbbabbb")
    print("abbbbbaaa")
    print("abbbbbaab")
    print("abbbbbaba")
    print("abbbbbabb")
    print("abbbbbbaa")
    print("abbbbbbab")
    print("abbbbbbba")
    print("abbbbbbbb")
if N == 10:
    print("aaaaaaaaaa")
    print("aaaaaaaaab")
    print("aaaaaaaaba")
    print("aaaaaaaabb")
    print("aaaaaaabaa")
    print("aaaaaaabab")
    print("aaaaaaabba")
    print("aaaaaaabbb")
    print("aaaaaabaaa")
    print("aaaaaabaab")
    print("aaaaaababa")
    print("aaaaaababb")
    print("aaaaaabbaa")
    print("aaaaaabbab")
    print("aaaaaabbba")
    print("aaaaaabbbb")
    print("aaaaabaaaa")
    print("aaaaabaaab")
    print("aaaaabaaba")
    print("aaaaabaabb")
    print("aaaaababaa")
    print("aaaaababab")
    print("aaaaababba")
    print("aaaaababbb")
    print("aaaaabbaaa")
    print("aaaaabbaab")
    print("aaaaabbaba")
    print("aaaaabbabb")
    print("aaaaabbbaa")
    print("aaaaabbbab")
    print("aaaaabbbba")
    print("aaaaabbbbb")
    print("aaaabaaaaa")
    print("aaaabaaaab")
    print("aaaabaaaba")
    print("aaaabaaabb")
    print("aaaabaabaa")
    print("aaaabaabab")
    print("aaaabaabba")
    print("aaaabaabbb")
    print("aaaababaaa")
    print("aaaababaab")
    print("aaaabababa")
    print("aaaabababb")
    print("aaaababbaa")
    print("aaaababbab")
    print("aaaababbba")
    print("aaaababbbb")
    print("aaaabbaaaa")
    print("aaaabbaaab")
    print("aaaabbaaba")
    print("aaaabbaabb")
    print("aaaabbabaa")
    print("aaaabbabab")
    print("aaaabbabba")
    print("aaaabbabbb")
    print("aaaabbbaaa")
    print("aaaabbbaab")
    print("aaaabbbaba")
    print("aaaabbbabb")
    print("aaaabbbbaa")
    print("aaaabbbbab")
    print("aaaabbbbba")
    print("aaaabbbbbb")
    print("aaabaaaaaa")
    print("aaabaaaaab")
    print("aaabaaaaba")
    print("aaabaaaabb")
    print("aaabaaabaa")
    print("aaabaaabab")
    print("aaabaaabba")
    print("aaabaaabbb")
    print("aaabaabaaa")
    print("aaabaabaab")
    print("aaabaababa")
    print("aaabaababb")
    print("aaabaabbaa")
    print("aaabaabbab")
    print("aaabaabbba")
    print("aaabaabbbb")
    print("aaababaaaa")
    print("aaababaaab")
    print("aaababaaba")
    print("aaababaabb")
    print("aaabababaa")
    print("aaabababab")
    print("aaabababba")
    print("aaabababbb")
    print("aaababbaaa")
    print("aaababbaab")
    print("aaababbaba")
    print("aaababbabb")
    print("aaababbbaa")
    print("aaababbbab")
    print("aaababbbba")
    print("aaababbbbb")
    print("aaabbaaaaa")
    print("aaabbaaaab")
    print("aaabbaaaba")
    print("aaabbaaabb")
    print("aaabbaabaa")
    print("aaabbaabab")
    print("aaabbaabba")
    print("aaabbaabbb")
    print("aaabbabaaa")
    print("aaabbabaab")
    print("aaabbababa")
    print("aaabbababb")
    print("aaabbabbaa")
    print("aaabbabbab")
    print("aaabbabbba")
    print("aaabbabbbb")
    print("aaabbbaaaa")
    print("aaabbbaaab")
    print("aaabbbaaba")
    print("aaabbbaabb")
    print("aaabbbabaa")
    print("aaabbbabab")
    print("aaabbbabba")
    print("aaabbbabbb")
    print("aaabbbbaaa")
    print("aaabbbbaab")
    print("aaabbbbaba")
    print("aaabbbbabb")
    print("aaabbbbbaa")
    print("aaabbbbbab")
    print("aaabbbbbba")
    print("aaabbbbbbb")
    print("aabaaaaaaa")
    print("aabaaaaaab")
    print("aabaaaaaba")
    print("aabaaaaabb")
    print("aabaaaabaa")
    print("aabaaaabab")
    print("aabaaaabba")
    print("aabaaaabbb")
    print("aabaaabaaa")
    print("aabaaabaab")
    print("aabaaababa")
    print("aabaaababb")
    print("aabaaabbaa")
    print("aabaaabbab")
    print("aabaaabbba")
    print("aabaaabbbb")
    print("aabaabaaaa")
    print("aabaabaaab")
    print("aabaabaaba")
    print("aabaabaabb")
    print("aabaababaa")
    print("aabaababab")
    print("aabaababba")
    print("aabaababbb")
    print("aabaabbaaa")
    print("aabaabbaab")
    print("aabaabbaba")
    print("aabaabbabb")
    print("aabaabbbaa")
    print("aabaabbbab")
    print("aabaabbbba")
    print("aabaabbbbb")
    print("aababaaaaa")
    print("aababaaaab")
    print("aababaaaba")
    print("aababaaabb")
    print("aababaabaa")
    print("aababaabab")
    print("aababaabba")
    print("aababaabbb")
    print("aabababaaa")
    print("aabababaab")
    print("aababababa")
    print("aababababb")
    print("aabababbaa")
    print("aabababbab")
    print("aabababbba")
    print("aabababbbb")
    print("aababbaaaa")
    print("aababbaaab")
    print("aababbaaba")
    print("aababbaabb")
    print("aababbabaa")
    print("aababbabab")
    print("aababbabba")
    print("aababbabbb")
    print("aababbbaaa")
    print("aababbbaab")
    print("aababbbaba")
    print("aababbbabb")
    print("aababbbbaa")
    print("aababbbbab")
    print("aababbbbba")
    print("aababbbbbb")
    print("aabbaaaaaa")
    print("aabbaaaaab")
    print("aabbaaaaba")
    print("aabbaaaabb")
    print("aabbaaabaa")
    print("aabbaaabab")
    print("aabbaaabba")
    print("aabbaaabbb")
    print("aabbaabaaa")
    print("aabbaabaab")
    print("aabbaababa")
    print("aabbaababb")
    print("aabbaabbaa")
    print("aabbaabbab")
    print("aabbaabbba")
    print("aabbaabbbb")
    print("aabbabaaaa")
    print("aabbabaaab")
    print("aabbabaaba")
    print("aabbabaabb")
    print("aabbababaa")
    print("aabbababab")
    print("aabbababba")
    print("aabbababbb")
    print("aabbabbaaa")
    print("aabbabbaab")
    print("aabbabbaba")
    print("aabbabbabb")
    print("aabbabbbaa")
    print("aabbabbbab")
    print("aabbabbbba")
    print("aabbabbbbb")
    print("aabbbaaaaa")
    print("aabbbaaaab")
    print("aabbbaaaba")
    print("aabbbaaabb")
    print("aabbbaabaa")
    print("aabbbaabab")
    print("aabbbaabba")
    print("aabbbaabbb")
    print("aabbbabaaa")
    print("aabbbabaab")
    print("aabbbababa")
    print("aabbbababb")
    print("aabbbabbaa")
    print("aabbbabbab")
    print("aabbbabbba")
    print("aabbbabbbb")
    print("aabbbbaaaa")
    print("aabbbbaaab")
    print("aabbbbaaba")
    print("aabbbbaabb")
    print("aabbbbabaa")
    print("aabbbbabab")
    print("aabbbbabba")
    print("aabbbbabbb")
    print("aabbbbbaaa")
    print("aabbbbbaab")
    print("aabbbbbaba")
    print("aabbbbbabb")
    print("aabbbbbbaa")
    print("aabbbbbbab")
    print("aabbbbbbba")
    print("aabbbbbbbb")
    print("abaaaaaaaa")
    print("abaaaaaaab")
    print("abaaaaaaba")
    print("abaaaaaabb")
    print("abaaaaabaa")
    print("abaaaaabab")
    print("abaaaaabba")
    print("abaaaaabbb")
    print("abaaaabaaa")
    print("abaaaabaab")
    print("abaaaababa")
    print("abaaaababb")
    print("abaaaabbaa")
    print("abaaaabbab")
    print("abaaaabbba")
    print("abaaaabbbb")
    print("abaaabaaaa")
    print("abaaabaaab")
    print("abaaabaaba")
    print("abaaabaabb")
    print("abaaababaa")
    print("abaaababab")
    print("abaaababba")
    print("abaaababbb")
    print("abaaabbaaa")
    print("abaaabbaab")
    print("abaaabbaba")
    print("abaaabbabb")
    print("abaaabbbaa")
    print("abaaabbbab")
    print("abaaabbbba")
    print("abaaabbbbb")
    print("abaabaaaaa")
    print("abaabaaaab")
    print("abaabaaaba")
    print("abaabaaabb")
    print("abaabaabaa")
    print("abaabaabab")
    print("abaabaabba")
    print("abaabaabbb")
    print("abaababaaa")
    print("abaababaab")
    print("abaabababa")
    print("abaabababb")
    print("abaababbaa")
    print("abaababbab")
    print("abaababbba")
    print("abaababbbb")
    print("abaabbaaaa")
    print("abaabbaaab")
    print("abaabbaaba")
    print("abaabbaabb")
    print("abaabbabaa")
    print("abaabbabab")
    print("abaabbabba")
    print("abaabbabbb")
    print("abaabbbaaa")
    print("abaabbbaab")
    print("abaabbbaba")
    print("abaabbbabb")
    print("abaabbbbaa")
    print("abaabbbbab")
    print("abaabbbbba")
    print("abaabbbbbb")
    print("ababaaaaaa")
    print("ababaaaaab")
    print("ababaaaaba")
    print("ababaaaabb")
    print("ababaaabaa")
    print("ababaaabab")
    print("ababaaabba")
    print("ababaaabbb")
    print("ababaabaaa")
    print("ababaabaab")
    print("ababaababa")
    print("ababaababb")
    print("ababaabbaa")
    print("ababaabbab")
    print("ababaabbba")
    print("ababaabbbb")
    print("abababaaaa")
    print("abababaaab")
    print("abababaaba")
    print("abababaabb")
    print("ababababaa")
    print("ababababab")
    print("ababababba")
    print("ababababbb")
    print("abababbaaa")
    print("abababbaab")
    print("abababbaba")
    print("abababbabb")
    print("abababbbaa")
    print("abababbbab")
    print("abababbbba")
    print("abababbbbb")
    print("ababbaaaaa")
    print("ababbaaaab")
    print("ababbaaaba")
    print("ababbaaabb")
    print("ababbaabaa")
    print("ababbaabab")
    print("ababbaabba")
    print("ababbaabbb")
    print("ababbabaaa")
    print("ababbabaab")
    print("ababbababa")
    print("ababbababb")
    print("ababbabbaa")
    print("ababbabbab")
    print("ababbabbba")
    print("ababbabbbb")
    print("ababbbaaaa")
    print("ababbbaaab")
    print("ababbbaaba")
    print("ababbbaabb")
    print("ababbbabaa")
    print("ababbbabab")
    print("ababbbabba")
    print("ababbbabbb")
    print("ababbbbaaa")
    print("ababbbbaab")
    print("ababbbbaba")
    print("ababbbbabb")
    print("ababbbbbaa")
    print("ababbbbbab")
    print("ababbbbbba")
    print("ababbbbbbb")
    print("abbaaaaaaa")
    print("abbaaaaaab")
    print("abbaaaaaba")
    print("abbaaaaabb")
    print("abbaaaabaa")
    print("abbaaaabab")
    print("abbaaaabba")
    print("abbaaaabbb")
    print("abbaaabaaa")
    print("abbaaabaab")
    print("abbaaababa")
    print("abbaaababb")
    print("abbaaabbaa")
    print("abbaaabbab")
    print("abbaaabbba")
    print("abbaaabbbb")
    print("abbaabaaaa")
    print("abbaabaaab")
    print("abbaabaaba")
    print("abbaabaabb")
    print("abbaababaa")
    print("abbaababab")
    print("abbaababba")
    print("abbaababbb")
    print("abbaabbaaa")
    print("abbaabbaab")
    print("abbaabbaba")
    print("abbaabbabb")
    print("abbaabbbaa")
    print("abbaabbbab")
    print("abbaabbbba")
    print("abbaabbbbb")
    print("abbabaaaaa")
    print("abbabaaaab")
    print("abbabaaaba")
    print("abbabaaabb")
    print("abbabaabaa")
    print("abbabaabab")
    print("abbabaabba")
    print("abbabaabbb")
    print("abbababaaa")
    print("abbababaab")
    print("abbabababa")
    print("abbabababb")
    print("abbababbaa")
    print("abbababbab")
    print("abbababbba")
    print("abbababbbb")
    print("abbabbaaaa")
    print("abbabbaaab")
    print("abbabbaaba")
    print("abbabbaabb")
    print("abbabbabaa")
    print("abbabbabab")
    print("abbabbabba")
    print("abbabbabbb")
    print("abbabbbaaa")
    print("abbabbbaab")
    print("abbabbbaba")
    print("abbabbbabb")
    print("abbabbbbaa")
    print("abbabbbbab")
    print("abbabbbbba")
    print("abbabbbbbb")
    print("abbbaaaaaa")
    print("abbbaaaaab")
    print("abbbaaaaba")
    print("abbbaaaabb")
    print("abbbaaabaa")
    print("abbbaaabab")
    print("abbbaaabba")
    print("abbbaaabbb")
    print("abbbaabaaa")
    print("abbbaabaab")
    print("abbbaababa")
    print("abbbaababb")
    print("abbbaabbaa")
    print("abbbaabbab")
    print("abbbaabbba")
    print("abbbaabbbb")
    print("abbbabaaaa")
    print("abbbabaaab")
    print("abbbabaaba")
    print("abbbabaabb")
    print("abbbababaa")
    print("abbbababab")
    print("abbbababba")
    print("abbbababbb")
    print("abbbabbaaa")
    print("abbbabbaab")
    print("abbbabbaba")
    print("abbbabbabb")
    print("abbbabbbaa")
    print("abbbabbbab")
    print("abbbabbbba")
    print("abbbabbbbb")
    print("abbbbaaaaa")
    print("abbbbaaaab")
    print("abbbbaaaba")
    print("abbbbaaabb")
    print("abbbbaabaa")
    print("abbbbaabab")
    print("abbbbaabba")
    print("abbbbaabbb")
    print("abbbbabaaa")
    print("abbbbabaab")
    print("abbbbababa")
    print("abbbbababb")
    print("abbbbabbaa")
    print("abbbbabbab")
    print("abbbbabbba")
    print("abbbbabbbb")
    print("abbbbbaaaa")
    print("abbbbbaaab")
    print("abbbbbaaba")
    print("abbbbbaabb")
    print("abbbbbabaa")
    print("abbbbbabab")
    print("abbbbbabba")
    print("abbbbbabbb")
    print("abbbbbbaaa")
    print("abbbbbbaab")
    print("abbbbbbaba")
    print("abbbbbbabb")
    print("abbbbbbbaa")
    print("abbbbbbbab")
    print("abbbbbbbba")
    print("abbbbbbbbb")

Submission status: Wrong Answer

Solution code:
n=int(input())


tree = [[0,1]]
for _ in range(n-1):
    tree = [ t+[i]  for t in tree for i in range(1,t[-1]+2) ]

for t in tree:
    print( "".join([chr(ord("a")+tt-1) for tt in t[1:] ] ) )

Submission status: Wrong Answer

Solution code:
N = int(input())

que = ['a']
res = []
for i in range(1, N):
    for q in que:
        res.append(q + 'a')
        res.append(q + 'b')
    que = res
    res = []
    
for q in que:
    print(q)

Submission status: Wrong Answer

Solution code:
n=int(input())
l = ['a','b','c','d','e','f','g','h','i','j','k','l']
arr = ['a']
for i in range(2,n+1):
    temp = []
    for x in l[:i]:
        for y in arr:
            temp.append(y+x)
    arr = temp
arr.sort()
for x in arr:
    print(x)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from string import ascii_lowercase

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()

ans = []
def rec(i, S):
    if i == N:
        ans.append(S)
        return
    for j, c in enumerate(ascii_lowercase):
        rec(i+1, S+c)
        if i == j or (i >= 1 and ord(S[-1]) + 1 == ord(c) and c not in S):
            break
rec(0, '')
ans.sort()
[print(s) for s in ans]

Submission status: Wrong Answer

Solution code:
n = int(input())
s = 'abcdefghij'

def ans(a, c):
    if len(a)==n-1:
        for i in range(c):
            print(a+s[i])
    else:
        for i in range(c):
            a+=s[i]
            ans(a, i+2)
            a=a[0:-1]

ans('', 1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

chars = ["a", "b", "c", "d", "e", "f", "g", "h", "j", "k"]

def get_str(seq_list):
    result = []
    for seq in seq_list:
        used_char_num = len(set(seq))
        for i in range(used_char_num + 1):
            result.append(seq + chars[i])
    return result

N = int(input())

seq_list = ["a"]
for i in range(N - 1):
    tmp = seq_list[:]
    seq_list = get_str(tmp)

for s in seq_list:
    print(s)

Submission status: Wrong Answer

Solution code:
N=input()
A="abcdefghij"

S=["a"]
for n in range(2,N+1):
    temp=[]
    for s in S:
        for i in range(n):
            if i==n-1:
                if s[-1]==A[i-1]:
                    temp.append(s+A[i])
            else:
                temp.append(s+A[i])
    S=temp

S.sort()
for x in S:
    print x

Submission status: Wrong Answer

Solution code:
import sys
import time
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
N = int(input())

groups = []

def dfs(s, n):
    if n == N:
        bits = [-1] * N
        for i, ss in enumerate(s):
            if bits[i] != -1:
                continue
            bits[i] = s.index(ss)
        if bits not in groups:
            groups.append(bits)
            print(s)
            return True
        return False
    for ns in 'abcdefghijklmnopqrstuvwxyz':
        if dfs(s+ns, n+1):
            continue
        else:
            return True

dfs('', 0)

Submission status: Wrong Answer

Solution code:
def chg(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out

N = int(input())
li = list("abcdefghij")

for i in range(2**N):
    mm = str(chg(i,N)).zfill(N)
    cnt = 0
    for j in range(N):
        a = int(mm[j])
        if a<=cnt:
            continue
        elif a-1==cnt:
            cnt += 1
            continue
        break
    else:
        for j in range(N):
            print(li[int(mm[j])],end="")
        print()

Submission status: Wrong Answer

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

dpn = ['']
dpp = []
for i in range(n):
    for j in dpn:
        for k in al[0:i+1]:
            if i != n-1:
                dpp.append(j+k)
            else:
                print(j+k)
    if i!= n-1:
        dpn = dpp
        dpp = []

Submission status: Wrong Answer

Solution code:
alpha = "abcdefghij"
N = int(input())
anss = []
for i in range(1, N+1):
    substr = alpha[:i]
    s = "a" * (N-i) + substr

    if i in [1, N]:
        anss.append(s)

    elif i % 2 == 0:
        last = s[-1]
        s = s[:-1]
        for i in reversed(range(1, N)):
            temp = s[:i] + last + s[i:]
            anss.append(temp)
    else:
        first = s[0]
        s = s[1:]
        for i in range(1, N):
            temp = s[:i] + first + s[i:]
            anss.append(temp)

for ans in anss:
    print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

ans='a'*N
ans_code=[0]*N
for i in range(N):
    ans_code[i]=ord(ans[i])
#print(ans_code)

for k in ans_code:
        print(chr(k),end='')
print('')

for i in range(1,N):
    for j in range(1,i+1):
        ans_code[-j]+=1
    #print(ans_code)
    for k in ans_code:
        print(chr(k),end='')
    print('')
    

"""
ans[-1]
for i in range(N):
    ans[]
"""

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
l = [i for i in range(1, n+1)]
alpha_dict = {}
for i,c in enumerate(range(ord('A'),ord('Z')+1)):
  #alpha_dict[chr(c)] = i + 1
  alpha_dict[i+1] = chr(c)

ans = set()
for v in itertools.product(range(1, n+1), repeat=n):
  m = min(v)
  print(v, m)
  used = []
  dic = {i:0 for i in range(n+1)}
  tmp = ""
  for u in v:
    if dic[u] == 0:
      dic[u] = len(used)+1
      used += [u]
      tmp += str(alpha_dict[dic[u]]).lower()
    else:
      tmp += str(alpha_dict[dic[u]]).lower()
  print(tmp)
  ans.add(tmp)

ans = sorted(list(ans))
for v in ans:
  print(v)

Submission status: Wrong Answer

Solution code:
from copy import deepcopy


def f(num,N,S):
    alphabet = ["a","b","c","d","e","f","g","h","i","j","k"]
    if N == num:
        for i in range(len(S)):
            print(S[i])
        return
    else:
        tmp = []
        length = len(S)
        for i in range(length):
            if i == 0:
                tmp.append(S[0]+"a")
                tmp.append(S[0]+"b")
            elif i == length-1:
                for j in range(num+1):
                    tmp.append(S[-1]+alphabet[j])
            else:
                for j in range(num):
                    tmp.append(S[i]+alphabet[j])
        S = deepcopy(tmp)
        S.sort()
        f(num+1,N,S)

N = int(input())
f(1,N,["a"])