import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int q = in.nextInt(); for(int a0 = 0; a0 < q; a0++){ int len = in.nextInt(); int c = in.nextInt(); Integer[] arr = new Integer[len]; for(int i=1;i<=len;i++){ arr[i-1] = i; } List results = new ArrayList<>(); makePerm1(arr,0,arr.length,results,c); if(results.size()>0){ System.out.println(results.get(0)); System.out.print("\n"); }else{ System.out.println(-1); } } } public static class Tuple{ T1 t1; T2 t2; public Tuple(T1 t1, T2 t2) { this.t1 = t1; this.t2 = t2; } } private static Tuple,Integer> lena_sort(List nums,int old_comp) { if (nums.size() <= 1) { return new Tuple(nums,0); } int pivot = nums.get(0); List less = new ArrayList<>(); List more = new ArrayList<>(); int comparisons =0; for (int i = 1; i < nums.size(); ++i) { // Comparison comparisons++; if (nums.get(i) < pivot) { less.add(nums.get(i)); } else { more.add(nums.get(i)); } } Tuple,Integer> sorted_less = lena_sort(less,old_comp); sorted_less.t1.add(pivot); Tuple,Integer> sorted_more = lena_sort(more,old_comp); sorted_less.t1.addAll(sorted_more.t1); return new Tuple(sorted_less.t1,comparisons+sorted_less.t2+sorted_more.t2); } private static void makePerm1(Integer[] str, int i, int n,List results,int rc) { if(i==n){ Tuple,Integer> t = lena_sort(Arrays.asList(str),0); if(t.t2==rc) { // System.out.println(Arrays.toString(str)+":"+t.t2); StringBuffer sb = new StringBuffer(); for(Integer t1: str){ sb.append(t1).append(" "); } results.add(sb.toString().trim()); } // System.out.println(Arrays.toString(str)); }else{ for(int j=i;j