After grading too many tests, Mr. DeMello decided to start grading strings instead.
Mr. DeMello has the correct -letter, lowercase string, , which he will use to grade the other strings.
Now, Mr. DeMello considers all possible -letter, lowercase strings and grades them by finding the minimum distance between each letter in the string (e.g., a
and z
have a distance of ), summing it up for their total score.
Since Mr. DeMello knows all his students will get a score of at most , can you tell him all the possible strings that his students can get?
Input Specification
The first line will contain , the maximum score his students can achieve.
The second line will contain , the intended -letter string.
Output Specification
Output all possible strings in sorted alphabetical order (e.g., abc
should appear before bac
).
Sample Input
1
abcd
Sample Output
aacd
abbd
abcc
abcd
abce
abdd
accd
bbcd
zbcd
Comments