Олимпиадный тренинг

Задача 38636. By number


Задача

Темы: Перестановки
Find the permutation by its number in lexicographic order.

Input
The first line of the input contains the number N (1 <= N <= 12) – the number of elements in the permutation, in the second – number K (1 <= K <= N!) – permutation number.

Imprint
Print N numbers – desired permutation.
Examples
# Input Output
1 3
2
1 3 2