eolymp
bolt
Try our new interface for solving problems
Problems

Permutation by number

Permutation by number

Find a permutation by its number in the lexicographical order. \InputFile The first line of the input file is written the number \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{12}) - the number of elements in the permutation. In the second row the number of \textbf{K} (\textbf{1} ≤ \textbf{K} ≤ \textbf{N!}) - number of the permutation. \OutputFile The output file output of \textbf{N} numbers - the desired permutation.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3
1
Output example #1
1 2 3