#include #include #include #include #include using namespace std; #define ll long long const int N = 100005; ll l[N], r[N]; int find_best(int l1, int r1, int l2, int r2, int need){ /* while(r1 - l1 > 3){ int m1 = l1 + (r1 - l1) / 3; int m2 = r1 - (r1 - l1) / 3; int sec = need - m1, diff1, diff2; if(l2 > sec) diff1 = l2 - sec; else if(r2 < sec) diff1 = sec - r2; else return m1; sec = need - m2; if(l2 > sec) diff2 = l2 - sec; else if(r2 < sec) diff2 = sec - r2; else return m2; if(diff1 < diff2) r1 = m2; else l1 = m1; } */ for(int i = l1;i <= r1;++ i){ int sec = need - i; if(l2 <= sec && sec <= r2) return i; } while(1); return l1; } void out(int n, int x, int from, int to){ if(from > to) return; -- n; int need = x - n; int l1 = 0, r1 = n / 2 + (n & 1); while(r1 - l1 > 1){ int mid = (l1 + r1) >> 1; int sec = n - mid; if(r[mid] + r[sec] < need) r1 = mid; else l1 = mid; } if(l[l1] + l[n - l1] <= need && need <= r[l1] + r[n - l1]){ printf("%d ", from + l1); int x = find_best(l[l1], r[l1], l[n - l1], r[n - l1], need); out(l1, x, from, from + l1 - 1); out(n - l1, need - x, from + l1 + 1, to); } else { printf("%d ", from + r1); int x = find_best(l[r1], r[r1], l[n - r1], r[n - r1], need); out(r1, x, from, from + r1 - 1); out(n - r1, need - x, from + r1 + 1, to); } } int main() { l[1] = r[1] = 0; for(int i = 2;i <= 100000;++ i){ r[i] = i - 1 + r[i - 1]; l[i] = i - 1 + l[(i - 1) / 2] + l[(i - 1) / 2 + (~i & 1)]; } int q; scanf("%d", &q); while(q --){ int n, x; scanf("%d%d", &n, &x); if(l[n] <= x && x <= r[n]){ out(n, x, 1, n); putchar('\n'); } else { puts("-1"); } } return 0; }