Author: | A. Baranov | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 512 Mb | |
Output file: | Standard output |
A palindrome is a string of characters that reads equally in both directions (left to right and right to left).
Given an arbitrary string S, consider an lexicographically ordered list of all the different palindromes that can be obtained by deleting and rearranging characters in the original string.
It is required to exclude from the specified list those palindromes which are lexicographically less than given string T.
If after that list is still longer than n, the extra palindromes from the end should also be removed.
The first two lines of the input contain strings S and T, consisting of digits and lowercase letters of the Latin alphabet.
They are followed by an integer n.
The output must contain all the remaining palindromes in the list in lexicographic order.
If there are none, the output should be an empty string.
0 < |T| ≤ |S| ≤ 100,
0 < n ≤ 2 ⋅ 104
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|