Permutations
You are given N(1 ≤ N ≤ 20) numbers from 1 to N. You have to write their K(1 ≤ K ≤ N!)-th lexicographic permutation.
InputThe first line of standard input contains the two integers N,K.
OutputThe output should contain K-th lexicographic permutation.
Input:
3 1
Output:
1 2 3
Input:
Output:
3 2
Output:
1 3 2
Input:
Output:
10 7
Output:
1 2 3 4 5 6 8 7 9 10
Input:
Output:
10 3628800
Output:
10 9 8 7 6 5 4 3 2 1
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.