Permutation

Given a subsequence of a permutation of n elements (1, 2, . . . , n), you have to find the K-th permutation in lexicographic order that contains the subsequence given. For example: If you have 1, 3, 2 and n equals to 4 you can obtain these permutations: 1, 3, 2, 4 1, 3, 4, 2 1, 4, 3, 2 4, 1, 3, 2 Input Input file contains several test cases. The first line of the test case contains three integers n (1 ≤ n ≤ 250), m (0 < m ≤ n) m is the number of the elements of the subsequence and K, in the next line contains m integers. Output For each test case write a K-th permutation that satisfies the condition, one per line. Notice: K-th position always exists. Sample Input 431 132 433 132 434 132 8 4 1000 8241 Sample Output 1324 1432 4132 82471563