import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.util.stream.Collectors; 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(); // your code goes here System.out.println(getArrays(len, c)); } } private static String getArrays(int len, int c) { if (c > len*len) { return "-1"; } for (int i = 0; i < len; i++) { List arr = new ArrayList(); for (int j = 0; j < len; j++) { int k = ((j + i) % len) + 1; arr.add(k); } int comp = checkForComparisons(arr, 0, c); if (comp == c) { return String.join(" ", arr.stream().map(String::valueOf) .collect(Collectors.toList())); } } return "-1"; } private static int checkForComparisons(List arr, int comp, int c) { if (comp > c) { return -1; } if (arr.size() <= 1) { return comp; } int pivot = arr.get(0); List less = new ArrayList(); List more = new ArrayList(); for (int i = 1; i < arr.size(); ++i) { // Comparison if (arr.get(i) < pivot) { less.add(arr.get(i)); } else { more.add(arr.get(i)); } comp++; } return checkForComparisons(less, 0, c-comp) + comp + checkForComparisons(more, 0, c-comp); } }