# Just Some Permutations - 2

Given N, L and K. Dexter wants to find the lexicographically K-th permutation of the numbers 1, 2, . . . , N such that the length of the longest increasing subsequence (LIS) of the permutation (treat the permutation as a sequence of numbers) is exactly L (see notes for the definitions). A permutation A1, A2, . . . , AN of N numbers is lexicographically smaller than another permutation B1,B2,...,BN,ifAi <Bi forsomeiandAj =Bj forallj<i. For example when N = 4, L = 2 the first four such permutations lexicographically are: {1, 4, 3, 2}, {2,1,4,3},{2,4,1,3}and{2,4,3,1}. But{1,4,2,3}isnotvalidasthelengthoftheLISis3here. Input First line of the input contains an integer T (≤ 30) which is the number of test cases. Each of the following T lines contain three integers N (1 < N < 14) , L (1 ≤ L ≤ N) and K (1 ≤ K ≤ 109). There are at most 15 cases in the input file where N = 13. Output For each case, output the case number, followed by the lexicographically K-th permutation of first N numbers, such that, the length of LIS of that permutation is exactly L. If there are less than K permutations, output ‘-1’. Notes: A subsequence of a sequence is a sequence formed from the given sequence by deleting some of the elements without disturbing the relative positions of the remaining elements and LIS is defined as length of longest such subsequence where the values are strictly increasing. So, if the sequence is {2, 4, 1, 3}, LIS is 2 and {2, 3}, {1, 3}, {2, 4} are some LIS of the sequence. Sample Input 4 423 424 4 2 15 4 2 13 Sample Output Case 1: 2 4 1 3 Case 2: 2 4 3 1 Case 3: -1 Case 4: 4 3 1 2