#include using namespace std; const int MAXN = 1e5; typedef long long Long; Long g[MAXN + 10], ff[MAXN + 10]; void init() { g[0] = g[1] = 0; for(int i = 2; i <= MAXN; i++) { g[i] = i-1 + g[(i+1)/2-1] + g[i-(i+1)/2]; } ff[0] = ff[1] = 0; for(int i = 2; i <= MAXN; i++) { ff[i] = i * 1LL * (i - 1) / 2; } } void calc(int a, int b, int c) { if(a > b) return; if(a == b) { printf("%d ", a); return; } cerr << "calc(" << a << " " << b << " " << c << ")\n"; int lo = a, hi = (a+b)/2; while(hi-lo > 1) { cerr << "[" << lo << " " << hi << "]\n"; int m = (lo + hi) / 2; if(c <= b-a + ff[m-a] + ff[b-m]) lo = m; else hi = m; } if(c <= b-a + ff[hi-a]+ff[b-hi]) lo = hi; printf("%d ", lo); int x = lo - a, y = b - lo; if(c <= g[x]+ff[y]) { calc(a, lo-1, g[x]); calc(lo+1, b, c-g[x]); } else if(c <= ff[x]+g[y]) { calc(a, lo-1, c-g[y]); calc(lo+1, b, g[y]); } else if(ff[x]+g[y] <= c) { calc(a, lo-1, ff[x]); calc(lo+1, b, c - ff[x]); } else { calc(a, lo-1, c - ff[y]); calc(lo+1, b, ff[y]); } } void solve(int n, int c) { if(c < g[n] || c > ff[n]) { printf("-1\n"); } else { calc(1,n, c); printf("\n"); } } int main() { init(); int Q; scanf("%d", &Q); for(int q = 0; q < Q; q++) { int n, c; scanf("%d%d", &n, &c); solve(n, c); } }