Problem: Yeah, we failed to make up a New Year legend for this problem.

A permutation of length n is an array of n integers such that every integer from 1 to n appears in it exactly once. 

An element y of permutation p is reachable from element x if x = y, or p_x = y, or p_{p_x} = y, and so on. 

The decomposition of a permutation p is defined as follows: firstly, we have a permutation p, all elements of which are not marked, and an empty list l. Then we do the following: while there is at least one not marked element in p, we find the leftmost such element, list all elements that are reachable from it in the order they appear in p, mark all of these elements, then cyclically shift the list of those elements so that the maximum appears at the first position, and add this list as an element of l. After all elements are marked, l is the result of this decomposition.

For example, if we want to build a decomposition of p = [5, 4, 2, 3, 1, 7, 8, 6], we do the following:

  1. initially p = [5, 4, 2, 3, 1, 7, 8, 6] (bold elements are marked), l = []; 
  2. the leftmost unmarked element is 5; 5 and 1 are reachable from it, so the list we want to shift is [5, 1]; there is no need to shift it, since maximum is already the first element; 
  3. p = [5, 4, 2, 3, 1, 7, 8, 6], l = [[5, 1]]; 
  4. the leftmost unmarked element is 4, the list of reachable elements is [4, 2, 3]; the maximum is already the first element, so there's no need to shift it; 
  5. p = [5, 4, 2, 3, 1, 7, 8, 6], l = [[5, 1], [4, 2, 3]]; 
  6. the leftmost unmarked element is 7, the list of reachable elements is [7, 8, 6]; we have to shift it, so it becomes [8, 6, 7]; 
  7. p = [5, 4, 2, 3, 1, 7, 8, 6], l = [[5, 1], [4, 2, 3], [8, 6, 7]]; 
  8. all elements are marked, so [[5, 1], [4, 2, 3], [8, 6, 7]] is the result. 



The New Year transformation of a permutation is defined as follows: we build the decomposition of this permutation; then we sort all lists in decomposition in ascending order of the first elements (we don't swap the elements in these lists, only the lists themselves); then we concatenate the lists into one list which becomes a new permutation. For example, the New Year transformation of p = [5, 4, 2, 3, 1, 7, 8, 6] is built as follows:

  1. the decomposition is [[5, 1], [4, 2, 3], [8, 6, 7]]; 
  2. after sorting the decomposition, it becomes [[4, 2, 3], [5, 1], [8, 6, 7]]; 
  3. [4, 2, 3, 5, 1, 8, 6, 7] is the result of the transformation. 



We call a permutation good if the result of its transformation is the same as the permutation itself. For example, [4, 3, 1, 2, 8, 5, 6, 7] is a good permutation; and [5, 4, 2, 3, 1, 7, 8, 6] is bad, since the result of transformation is [4, 2, 3, 5, 1, 8, 6, 7].

Your task is the following: given n and k, find the k-th (lexicographically) good permutation of length n.

Input

The first line contains one integer t (1 ≤ t ≤ 1000) — the number of test cases.

Then the test cases follow. Each test case is represented by one line containing two integers n and k (1 ≤ n ≤ 50, 1 ≤ k ≤ 10^{18}).

Output

For each test case, print the answer to it as follows: if the number of good permutations of length n is less than k, print one integer -1; otherwise, print the k-th good permutation on n elements (in lexicographical order).

Example

Input


5
3 3
5 15
4 13
6 8
4 2


Output


2 1 3 
3 1 2 5 4 
-1
1 2 6 3 4 5 
1 2 4 3 

Solution (in JAVA):

Solution:
//package educational.round79;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class E {
	InputStream is;
	PrintWriter out;
	String INPUT = "";
	
	void solve()
	{
		// 連続的に分割
		// 先頭からは最後の要素に移動
		
		// 1 2 3 4
		// 4 ? ? ?
		// (K-2)!
		
		long[] F = new long[50];
		F[0] = 1;
		for(int i = 1;i < 21;i++){
			F[i] = F[i-1] * i;
		}
		for(int i = 21;i < 50;i++){
			F[i] = F[i-1];
		}
		
		long I = 2000000000000000000L;
		long[] dp = new long[51];
		dp[0] = 1;
		for(int i = 1;i <= 50;i++){
			double q = 0;
			for(int j = 1;j <= i;j++){
				q += (double)dp[i-j] * (j-2 < 0 ? 1 : F[j-2]);
				dp[i] += dp[i-j] * (j-2 < 0 ? 1 : F[j-2]);
			}
			if(q > I){
				dp[i] = I;
			}
		}
		
		for(int T = ni();T > 0;T--){
			int n = ni();
			long K = nl()-1;
			if(K >= dp[n]){
				out.println(-1);
				continue;
			}
			for(int i = 0;i < n;){
				for(int j = i;j < n;j++){
					long num = i == j ? 1 : F[j-i-1];
					double numd = (double)num * dp[n-1-j];
					num *= dp[n-1-j];
//					tr(i, j, K, num);
					if(numd >= I || K < num){
						long which = K/dp[n-1-j];
						int[] per = kth(j-i+1, which, F);
//						tr("hai", i, j, which, per, dp[n-1-j]);
						for(int k = 0;k < per.length;k++){
							out.print((i+1+per[k]) + " ");
						}
						K %= dp[n-1-j];
						i = j+1;
						break;
					}else{
						K -= num;
					}
				}
			}
			assert K == 0;
			out.println();
		}
	}
	
	public int[] kth(int n, long K, long[] F)
	{
		int[] f = new int[n];
		if(n <= 1){
			return f;
		}
		Arrays.fill(f, -1);
		f[0] = n-1;
		long rem = (1L<<n-1)-1;
		for(int i = 1;i < n-1;i++){
			for(int j = 0;j < n;j++){
				if(rem<<~j<0){
					f[i] = j;
					int x;
					for(x = j;x != -1 && x != i;x = f[x]);
					if(x == -1){
						if(K < F[n-i-2]){
							rem ^= 1L<<j;
							break;
						}else{
							K -= F[n-i-2];
						}
					}
				}
			}
		}
		f[n-1] = Long.numberOfTrailingZeros(rem);
		return f;
	}
	
	public static int[] decPerm(long c, int n) {
		int[] a = new int[n];
		for (int i = n - 1; i >= 0; c /= n - i, i--) {
			a[i] = (int)(c % (n - i));
		}
		long rem = (1L << n) - 1;
		for(int i = 0;i < n;i++){
			long x = rem;
			for(int j = 0;j < a[i];j++, x &= x-1);
			
			a[i] = Long.numberOfTrailingZeros(x);
			rem ^= x&-x;
		}
		return a;
	}

	
	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);
		
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}
	
	public static void main(String[] args) throws Exception { new E().run(); }
	
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;
	
	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}
	
	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
	
	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }
	
	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}
	
	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}
	
	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}
	
	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}
		
		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}
	
	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}