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

Solution in C# (.NET Core 3.1.201) (judge verdict: Accepted)

/* C# template********************************
20.08.08 パナソニックプログラミングコンテスト2020. D - String Equivalence

問題文
この問題では、英小文字からなる文字列のみを考えます。

文字列 s,t は以下の条件を満たすとき 同型 であるといいます。

|s|=|t| である。任意の i,j に対し次のいずれかが成立する。si=sj かつ 
ti=tjsi≠sj かつ ti≠tjたとえば、abcac と zyxzx は同型ですが、abcac と ppppp は同型ではありません。

文字列 s は以下の条件を満たすとき 標準形 であるといいます。

任意の s と同型な文字列 t に対し、s≤t が成立する。ただしここで ≤ は辞書順での比較を表す。
たとえば、abcac は標準形ですが、zyxzx はそれより辞書順で小さい　abcac と同型のため標準形ではありません。

整数 N が与えられます。 長さ N の標準形の文字列を全て、辞書順で昇順で出力してください。

N = 1 to 10


a
aa
ab
aaa
aab
aba
abb
abc ...
와 같이 출력.

*********************************************/

using static System.Console; 
using static IOmacro.CsharpInput; 
using static IOmacro.CppInput;

namespace temp_name {
    using System;
    using System.Linq;
    using System.Collections.Generic;

    public class Run {
        
        int strLenIn;
        
        
        public void solve(string strNow, char max) {
            if (strNow.Length == strLenIn) {
                WriteLine(strNow);
                
            } else {
                for (char next = 'a'; next <= max; next++) {
                    if (next == max) {
                        solve(strNow + next, (char)(max + 1));
                    } else {
                        solve(strNow + next, max);
                    }
                }
            }
        }
        
        public void proc() {
            strLenIn = cin;
            
            solve("", 'a');
            
        }
    }
}

class program {
    
    static void Main(string[] args) {
        // var exStdIn = new System.IO.StreamReader(@"C:\Users\HAN\Desktop\VSC\input.txt"); System.Console.SetIn(exStdIn);
        var run = new temp_name.Run(); System.Console.SetOut(_writer); run.proc(); System.Console.Out.Flush();
    }
}


namespace IOmacro {
    //20.08.10 수정

    using System;
    using System.Linq;
    using System.IO;
    using System.Collections.Generic;

    public class CsharpInput {
        public static StreamWriter _writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        public const char separator = ' ';
        public static string _string { get { return Console.ReadLine(); } } public static string[] _stringa { get { return (Console.ReadLine().Split(separator)); } }
        public static int _int { get { return int.Parse(Console.ReadLine()); } } public static int[] _inta { get { return Console.ReadLine().Split(separator).Select(int.Parse).ToArray(); } }
        public static long _long { get { return long.Parse(Console.ReadLine()); } } public static long[] _longa { get { return Console.ReadLine().Split(separator).Select(long.Parse).ToArray(); } }
        public static double _double { get { return double.Parse(Console.ReadLine()); } } public static double[] _doublea { get { return Console.ReadLine().Split(separator).Select(double.Parse).ToArray(); } }
    }

    public class CppInput {
        public static CppInput cin => new CppInput();
        public const char separator = ' ';
        private static readonly Queue<string> _input = new Queue<string>();
        private CppInput() { }
        public static implicit operator string(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return _input.Dequeue();
        }
        public static implicit operator int(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return int.Parse(_input.Dequeue());
        }
        public static implicit operator long(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return long.Parse(_input.Dequeue());
        }
        public static implicit operator double(CppInput _) {
            if (_input.Count == 0) Console.ReadLine().Split(separator).foreachExtension(x => _input.Enqueue(x));
            return double.Parse(_input.Dequeue());
        }
    }

    public static class CEnumerableExtension {
        public delegate void Function<in T>(T val);
        public static void foreachExtension<T>(this IEnumerable<T> enumerable, Function<T> function) {
            foreach (var x in enumerable) function(x);
        }
    }
}