A vault dial is set by choosing an arrangement of n integer notches. List all distinct arrangements of the given multiset of notch values in lexicographic order, numbered starting from 0. Given an index r, output the arrangement at position r in that list. It is guaranteed that r is a valid index (0 ≤ r < number of distinct arrangements).
Input format
Line 1: two integers n and r.
Line 2: n space-separated integers, the multiset of notch values.
Output format
n space-separated integers on one line: the r-th arrangement in lexicographic order.
Constraints
- 1 ≤ n ≤ 8
- 0 ≤ r < number of distinct arrangements of the multiset
- 1 ≤ each value ≤ 1000000