#PANASONIC2020D. String Equivalence
String Equivalence
Score : points
Problem Statement
In this problem, we only consider strings consisting of lowercase English letters.
Strings and are said to be isomorphic when the following conditions are satisfied:
- holds.
- For every pair , one of the following holds:- and .
- and .
- and .
- and .
For example, abcac and zyxzx are isomorphic, while abcac and ppppp are not.
A string is said to be in normal form when the following condition is satisfied:
- For every string that is isomorphic to , holds. Here 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 . Print all strings of length that are in normal form, in lexicographically ascending order.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Assume that there are strings of length that are in normal form: in lexicographical order. Output should be in the following format:
1
a
2
aa
ab