#abc215c. [abc215_c]One More aab aba baa
[abc215_c]One More aab aba baa
Problem Statement
Find the -th lexicographically smallest string among the strings that are permutations of a string .
What is a permutation of a string?A string is said to be a permutation of a string when any character occurs the same number of times in and .
Constraints
- consists of lowercase English letters.
- There are at least distinct strings that are permutations of .
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
aab 2
Sample Output 1
aba
There are three permutations of a string aab
: \\{ aab
, aba
, baa
\\}. The -nd lexicographically smallest of them is aba
.
Sample Input 2
baba 4
Sample Output 2
baab
Sample Input 3
ydxwacbz 40320
Sample Output 3
zyxwdcba