Lena developed a sorting algorithm described by the following pseudocode:

lena_sort(array nums) {
    if (nums.size <= 1) {
        return nums;
    }
    pivot = nums[0];
    array less;
    array more;
    for (i = 1; i < nums.size; ++i) {
    	// Comparison
        if (nums[i] < pivot) {
            less.append(nums[i]);
        }
        else {
            more.append(nums[i]);
        }
    }
    sorted_less = lena_sort(less);
    sorted_more = lena_sort(more);
    ans = sorted_less + pivot + sorted_more;
    
    return ans;
}

We consider a comparison to be any time some $nums[i]$ is compared with $\textbf{pivot}$. 

You must solve $\textit{q}$ queries where each query $\boldsymbol{i}$ consists of some $len_i$ and $c_i$. For each query, construct an array of $len_i$ distinct elements in the inclusive range between $\mbox{1}$ and $\mathbf{10^{9}}$ that will be sorted by $\textbf{lena_sort}$ in exactly $c_i$ comparisons, then print each respective element of the unsorted array as a single line of $len_i$ space-separated integers; if no such array exists, print -1 instead.

Input Format

The first line contains a single integer denoting $\textit{q}$ (the number of queries). 

Each line $\boldsymbol{i}$ of the $\textit{q}$ subsequent lines contains two space-separated integers describing the respective values of $\mbox{len}_i$ (the length of the array) and $c_i$ (the number of comparisons) for query $\boldsymbol{i}$.

Constraints

$1\leq q\leq10^5$  
$1\leq len_i\leq10^5$  
$0\leq c_i\leq10^9$  
$1\leq$ the sum of $\mbox{len}_i$ over all queries $\leq10^{6}$

Output Format

Print the answer to each query on a new line. For each query $\boldsymbol{i}$, print $\mbox{len}_i$ space-separated integers describing each respective element in an unsorted array that Lena's algorithm will sort in exactly $c_i$ comparisons; if no such array exists, print -1 instead.  

Sample Input 0
2
5 6
5 100

Sample Output 0
4 2 1 3 5
-1

Explanation 0

We perform the following $q=2$ queries:

One array with $len=5$ elements is $[4,2,1,3,5]$. The sequence of sorting operations looks like this:

Run $\textbf{lena_sort}$ on $[4,2,1,3,5]$. Compare $pivot=4$ with $2$, $\mbox{1}$, $3$, and $5$ for a total of $\begin{array}{c}4\end{array}$ comparisons. We're then left with $less=[2,1,3]$ and $\textit{more=[5]}$; we only need to continue sorting $less$, as $\textit{more}$ is sorted with respect to itself because it only contains one element.
Run $\textbf{lena_sort}$ on $less=[2,1,3]$. Compare $pivot=2$ with $\mbox{1}$ and $3$ for a total of $2$ comparisons. We're then left with $less=[1]$ and $\textit{more}=[3]$, so we stop sorting.

We sorted $[4,2,1,3,5]$ in $4+2=6$ comparisons and $\boldsymbol{c=6}$, so we print 4 2 1 3 5 on a new line.

It's not possible to construct an array with $len=5$ elements that $\textbf{lena_sort}$ will sort in exactly $\boldsymbol{c=100}$ comparisons, so we print -1 on a new line.

Sample Input 1
3
1 0
4 6
3 2

Sample Output 1
1
4 3 2 1
2 1 3

Explanation 1

We perform the following $q=3$ queries:

We want an array with $len=1$ element that $\textbf{lena_sort}$ sorts in $\boldsymbol{c=0}$ comparisons; any array with $\mbox{I}$ element is already sorted (i.e., $\textbf{lena_sort}$ performs $\mbox{o}$ comparisons), so we choose $\left[\mbox{1}\right]$ as our array and print 1 on a new line. 

One array with $len=4$ elements is $[4,3,2,1]$; sorting it with $\textbf{lena_sort}$ looks like this:

$\textbf{lena_sort}$ on $[4,3,2,1]$. Compare $pivot=4$ with $3$, $2$, and $\mbox{I}$ for a total of $3$ comparisons. We're then left with $less=[3,2,1]$ and $\textit{more}=[]$; we only need to continue sorting $less$, as $\textit{more}$ is empty.
Run $\textbf{lena_sort}$ on $less=[3,2,1]$. Compare $pivot=3$ with $2$ and $\mbox{I}$ for a total of $2$ comparisons. We're then left with $less=[1,2]$ and $\textit{more}=[]$, so we only continue sorting $less$.
Run $\textbf{lena_sort}$ on $less=[2,1]$. Compare $pivot=2$ with $\mbox{I}$ for a total of $\mbox{1}$ comparison. We then stop sorting, as $less=[1]$ and $\textit{more}=[]$.

We sorted $[4,3,2,1]$ in $3+2+1=6$ comparisons and $\boldsymbol{c=6}$, so we print 4 3 2 1 on a new line.

One array with $len=3$ elements is $[2,1,3]$. When we run $\textbf{lena_sort}$ on it, we compare $pivot=2$ with $\mbox{1}$ and $3$ for a total of $2$ comparisons. We're then left with $less=[1]$ and $\textit{more}=[3]$, so we stop sorting.

We sorted $[2,1,3]$ in $2$ comparisons and $\boldsymbol{c=2}$, so we print 2 1 3 on a new line.

Difficulty: MEDIUM
Tags: Constructive algorithms

Starter code:

Solutions:
import sys
import math
mins = {0: 0, 1: 0}

def find_max(num):
	return (num + (1 - num % 2)) * (num // 2)

def find_min(num):
	if num in mins:
		return mins[num]
	if num % 2 == 1:
		if not num // 2 in mins:
			find_min(num // 2)
		mins[num] = num - 1 + mins[num // 2] + mins[num // 2]
		return mins[num]
	if not num // 2 in mins:
		find_min(num // 2)
	if not num // 2 - 1 in mins:
		find_min(num // 2 - 1)
	mins[num] = num - 1 + mins[num // 2] + mins[num // 2 - 1]
	return mins[num]
pivots = []

def find_min_max_wrapper(length, target, base=1):
	listofnews = find_min_max(length, target, base)
	while not listofnews is None:
		if listofnews == []:
			return True
		new_listofnews = []
		for news in listofnews:
			new_listofnews.extend(find_min_max(news[0], news[1], news[2]))
		listofnews = new_listofnews
	return False

def find_min_max(length, target, base):
	min_comps = find_min(length)
	max_comps = find_max(length)
	if target < min_comps or target > max_comps:
		return None
	if length == 1:
		if target == 0:
			pivots.append(base)
			return []
		return None
	if length == 0:
		if target == 0:
			return []
		return None
	new_target = target - (length - 1)
	for i in range(length):
		j = length - 1 - i
		min_i = find_min(i)
		max_i = find_max(i)
		min_j = find_min(j)
		max_j = find_max(j)
		if min_i + min_j <= new_target and max_i + max_j >= new_target:
			i_seed = min_i
			j_seed = new_target - min_i
			while j_seed > max_j:
				j_seed -= 1
				i_seed += 1
			pivots.append(base + i)
			return [(i, i_seed, base), (j, j_seed, base + i + 1)]
	return None

def construct(start, length, pivot, target):
	if start >= length:
		return []
	if length - start == 1:
		return [start]
	min_comps = find_min(length)
	max_comps = find_max(length)
	if target < min_comps or target > max_comps:
		return [-1]
	first = target - min_comps
	second = max_comps - target
	new_target = target - (length - 1)
	return [pivot[0] + start] + construct(start, start + pivot, ____, ____) + construct(start + pivot + 1, length, ____, ___)
sizes = [{0: []}, {0: [1]}]
i_done = 2
q = int(input().strip())
for a0 in range(q):
	(length, c) = input().strip().split(' ')
	(length, c) = [int(length), int(c)]
	if find_min_max_wrapper(length, c):
		print(' '.join([str(p) for p in pivots]))
	else:
		print('-1')
	pivots = []


import sys, queue
sys.setrecursionlimit(100000)
q = int(input().strip())
c_range = [range(0, 1), range(0, 1), range(1, 2)]
guide = {(0, 0): [], (1, 0): [1], (2, 1): [1, 2]}

def main(n, comp):
	case = list(range(1, n + 1))
	if n + 1 <= len(c_range):
		if comp not in c_range[n]:
			print(-1)
			return
	else:
		if (n - 1) * n / 2 < comp:
			print(-1)
			return
		for j in range(len(c_range), n + 1):
			start = c_range[j // 2].start + c_range[j // 2 - (not j % 2)].start + (j - 1)
			end = c_range[j - 1].stop + j - 1
			c_range.append(range(start, end))
		if c_range[n].start > comp:
			print(-1)
			return
	print(*recur(0, comp, n), sep=' ')

def recur(ref, oldcom, oldl):
	l = oldl
	if (l, oldcom) in guide:
		return list(map(lambda x: x + ref, guide[l, oldcom]))
	else:
		i = 0
		com = oldcom - (l - 1)
		while com not in range(c_range[i][0] + c_range[l - i - 1][0], c_range[i][-1] + c_range[l - i - 1][-1] + 1):
			i += 1
		if i == 0:
			l -= 1
			com -= l - 1
			front = [1]
			newref = 0
			while com in c_range[l - 1]:
				l -= 1
				com -= l - 1
				front.append(front[-1] + 1)
				newref += 1
			com += l - 1
			l += 1
		else:
			front = [i + 1]
			newref = i
		r1 = c_range[i]
		r2 = c_range[l - i - 1]
		j = r1[0]
		k = r2[-1]
		if com - j in r2:
			k = com - j
		else:
			j = com - k
		a = recur(0, j, i)
		b = recur(newref + 1, k, l - i - 1)
		new = front + a + b
		guide[oldl, oldcom] = new
		return list(map(lambda x: x + ref, new))
for a0 in range(q):
	(length, c) = input().strip().split(' ')
	(length, c) = [int(length), int(c)]
	main(length, c)


import sys
ans = [0 for _ in range(10 ** 5 + 10)]
upper_bounds = [0]
for i in range(1, 10 ** 5 + 1000):
	upper_bounds.append(upper_bounds[-1] + i)

def memo(func):
	memo = {}

	def wrapper(x):
		if not x in memo:
			v = func(x)
			memo[x] = v
		return memo[x]
	return wrapper

@memo
def lower_bound(n):
	if n == 0:
		return 0
	return n - 1 + 2 * lower_bound(n // 2) if n % 2 else n - 1 + lower_bound(n // 2) + lower_bound(n // 2 - 1)
lower_bounds = []
for i in range(10 ** 5 + 1000):
	lower_bounds.append(lower_bound(i))

def check(d, k):
	return d == -1 or lower_bounds[d] <= k <= d * (d - 1) // 2

def fill(x, y, k, l, r):
	if x > y:
		return
	d = y - x
	k -= d
	while d >= 0 and check(d, k):
		ans[l] = x
		l += 1
		x += 1
		d -= 1
		k -= d
	if d > 0:
		t = (x + y + 1) // 2
		while not check(y - t, k - lower_bounds[t - x]):
			t -= 1
		ans[l] = t
		fill(x, t - 1, lower_bounds[t - x], l + 1, l + t - x)
		fill(t + 1, y, k - lower_bounds[t - x], l + t - x + 1, r)
q = int(input().strip())
for a0 in range(q):
	(length, c) = input().strip().split(' ')
	(length, c) = [int(length), int(c)]
	if check(length, c):
		fill(1, length, c, 1, length)
		print(' '.join((str(x) for x in ans[1:length + 1])))
	else:
		print(-1)


LIM = 10 ** 5 + 10

def min_comparison_for_list_of_length(n):
	ncomps = 0
	remaining = n
	depth = 0
	width = 1
	while remaining:
		to_remove = min(remaining, width)
		ncomps += to_remove * depth
		remaining -= to_remove
		depth += 1
		width *= 2
	return ncomps

def max_comparison_for_list_of_length(n):
	return n * (n - 1) // 2
lower_bound_of = list(map(min_comparison_for_list_of_length, range(LIM)))
upper_bound_of = list(map(max_comparison_for_list_of_length, range(LIM)))

class Tree(object):

	def build_list(self):
		arr = []
		stack = [(1, self)]
		while stack:
			(offset, node) = stack.pop()
			if type(node) == Branch:
				arr.append(offset + node.left.size)
				stack.append((offset + node.left.size + 1, node.right))
				stack.append((offset, node.left))
			elif node == leaf:
				arr.append(offset)
		return arr

class Branch(Tree):

	def __init__(self, left, right):
		self.left = left
		self.right = right
		self.size = left.size + right.size + 1

class _Void(Tree):
	size = 0
void = _Void()

class _Leaf(Tree):
	size = 1
leaf = _Leaf()

class Impossible(Tree):

	def build_list(self):
		return [-1]
full_tree_cache = {0: void, 1: leaf, 2: Branch(leaf, void), 3: Branch(leaf, leaf)}
tree_cache = dict()
tree_cache[0, 0] = void
tree_cache[1, 0] = leaf
tree_cache[2, 1] = Branch(leaf, void)
last_key = (2, 1)
for n in range(3, LIM):
	key = (n, upper_bound_of[n])
	tree_cache[key] = Branch(tree_cache[last_key], void)
	last_key = key

def get_tree(n, c):
	key = (n, c)
	if key not in tree_cache:
		tree = build_tree(n, c)
		tree_cache[key] = build_tree(n, c)
	return tree_cache[key]

def find_split(n, c):
	c -= n - 1
	for nleft in range((n - 1) // 2 + 1):
		nright = n - 1 - nleft
		lower = lower_bound_of[nleft] + upper_bound_of[nright]
		upper = upper_bound_of[nleft] + upper_bound_of[nright]
		if lower <= c <= upper:
			return ((nleft, c - upper_bound_of[nright]), (nright, upper_bound_of[nright]))
	for nleft in reversed(range((n - 1) // 2 + 1)):
		nright = n - 1 - nleft
		lower = lower_bound_of[nleft] + lower_bound_of[nright]
		upper = upper_bound_of[nleft] + upper_bound_of[nright]
		if lower <= c <= upper:
			if upper_bound_of[nleft] + lower_bound_of[nright] <= c:
				return ((nleft, upper_bound_of[nleft]), (nright, c - upper_bound_of[nleft]))
			else:
				return ((nleft, c - lower_bound_of[nright]), (nright, lower_bound_of[nright]))

def build_tree(n, c):
	if c < lower_bound_of[n] or c > upper_bound_of[n]:
		return Impossible()
	if n in (0, 1):
		return leaf
	(original_n, original_c) = (n, c)
	depth = 0
	while n > 3 and lower_bound_of[n - 1] <= c - (n - 1) <= upper_bound_of[n - 1]:
		depth += 1
		c -= n - 1
		n -= 1
	((nleft, cleft), (nright, cright)) = find_split(n, c)
	node = Branch(get_tree(nleft, cleft), get_tree(nright, cright))
	for _ in range(depth):
		node = Branch(node, void)
	return node
assert Branch(Branch(leaf, leaf), leaf).build_list() == [4, 2, 1, 3, 5]

def solve(n, c):
	return ' '.join(map(str, build_tree(n, c).build_list()))
for _ in range(int(input())):
	(n, c) = map(int, input().split())
	print(solve(n, c))


import sys
from collections import deque
from itertools import chain
debug = False
lbm = {0: 0, 1: 0}
lbl = 1

def ub(sz):
	return sz * (sz - 1) // 2

def lb(sz):
	if sz in lbm:
		return lbm[sz]
	v = sz - 1
	c1 = (sz - 1) // 2
	c2 = sz - 1 - c1
	v += lb(c1) + lb(c2)
	lbm[sz] = v
	return v
memo = {0: {0: []}, 1: {0: [0]}}

def explorearrays():
	for size in range(2, 20):
		thislen = {}
		c0 = size - 1
		for pivot in range(size):
			len1 = pivot
			len2 = size - pivot - 1
			print(size, pivot, len1, len2)
			for (c1, l1) in memo[len1].items():
				for (c2, l2) in memo[len2].items():
					cmps = c0 + c1 + c2
					if cmps not in thislen:
						thislen[cmps] = [pivot] + l1 + list(map(lambda x: x + pivot + 1, l2))
		memo[size] = thislen

def findbiggest(sz, cs):
	lo = 0
	hi = (sz + 1) // 2
	while lo < hi:
		mid = (hi + lo) // 2
		c1 = mid
		c2 = sz - c1
		if ub(c1) + ub(c2) < cs:
			hi = mid
		elif lb(c1) + lb(c2) > cs:
			lo = mid + 1
		else:
			return mid
	return lo
arrs = {(0, 0): [], (1, 0): [0]}

def getarray(size, comparisons):
	st = deque()
	st.append((size, comparisons, 0))
	arr = []
	while st:
		(sz, cmps, lo) = st.pop()
		least = lb(sz)
		most = ub(sz)
		if debug:
			print('Searching for array of length %d with %d cmps (%d..%d)' % (sz, cmps, least, most))
		if (sz, cmps) in arrs:
			if debug:
				print('using memod version')
			arr.extend(list(map(lambda x: x + lo, arrs[sz, cmps])))
			continue
		if cmps < least or cmps > most:
			return None
		if cmps == most:
			if debug:
				print('ub hit, using in-order set')
			ans = [x for x in range(sz)]
			arrs[sz, cmps] = ans
			arr.extend(list(map(lambda x: x + lo, ans)))
			continue
		totcmps = cmps - (sz - 1)
		c1 = findbiggest(sz - 1, totcmps)
		c2 = sz - 1 - c1
		pivot = lo + c1
		arr.append(pivot)
		if debug:
			print('Chose pivot of %d, splitting into (%d,%d)' % (c1 + lo, c1, c2))
		c1cs = ub(c1)
		if totcmps - c1cs < lb(c2):
			c1cs = lb(c1)
			if debug:
				print('Too low; corrected')
		if totcmps - c1cs > ub(c2):
			if debug:
				print('Too high.')
		if c1 > 0:
			st.append((c1, c1cs, lo))
		if c2 > 0:
			st.append((c2, totcmps - c1cs, lo + c1 + 1))
	return arr
q = int(input().strip())
for a0 in range(q):
	(len, c) = input().strip().split(' ')
	(len, c) = [int(len), int(c)]
	arr = getarray(len, c)
	if arr:
		print(' '.join(map(lambda x: str(x + 1), arr)))
	else:
		print(-1)


import math
import os
import random
import re
import sys
mns = [0, 0]
for i in range(2, 100001):
	mns.append(i - 1 + mns[i // 2] + mns[(i - 1) // 2])

def mxs(i):
	return i * (i - 1) // 2

def lena(n, c):
	if not mns[n] <= c <= mxs(n):
		return -1
	result = n * [-1]
	stk = [(n, c, 0, 1)]
	while stk:
		(n, c, ofs, ofs2) = stk.pop()
		while n:
			c -= n - 1
			for i in range(n):
				if mns[i] + mns[n - 1 - i] <= c <= mxs(i) + mxs(n - 1 - i):
					c1 = min(max(c, max(mns[i], c - mxs(n - 1 - i))), min(mxs(i), c - mns[n - 1 - i]))
					result[ofs] = i + ofs2
					if i:
						stk.append((i, c1, ofs + 1, ofs2))
					(n, c, ofs, ofs2) = (n - i - 1, c - c1, ofs + i + 1, ofs2 + i + 1)
					break
	return result
q = int(input())
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	x = lena(l, c)
	print(x if x == -1 else ' '.join(map(str, x)))


def search(start, end, is_good):
	while start < end:
		mid = (start + end) // 2
		if is_good(mid):
			end = mid
		else:
			start = mid + 1
	return start

def compute_min(n):
	r = [0] * (n + 1)
	for i in range(2, n + 1):
		r[i] = r[i >> 1] + r[i - (i >> 1) - 1] + i - 1
	return r
mins = compute_min(10 ** 5)
maxs = [i * (i - 1) // 2 for i in range(10 ** 5 + 1)]

def solvable(n, c):
	return mins[n] <= c <= maxs[n]

def solve(l, c):
	stack = [(l, c, 1)]
	result = []
	while stack:
		(n, c, offset) = stack.pop()
		c -= n - 1
		if n > 1:
			mid = n // 2
			pivot = search(1, mid + 1, lambda i: maxs[i] + maxs[n - i - 1] < c) - 1
			yield (offset + pivot)
			right = mins[n - pivot - 1]
			left = min(maxs[pivot], c - right)
			right = c - left
			stack.append((n - pivot - 1, right, pivot + offset + 1))
			stack.append((pivot, left, offset))
		elif n == 1:
			yield offset

def main():
	q = int(input())
	for _ in range(q):
		(l, c) = [int(x) for x in input().split()]
		if solvable(l, c):
			print(' '.join((str(x) for x in solve(l, c))))
		else:
			print('-1')
main()


def search(start, end, is_good):
	while start < end:
		mid = (start + end) // 2
		if is_good(mid):
			end = mid
		else:
			start = mid + 1
	return start

def compute_min(n):
	r = [0] * (n + 1)
	for i in range(2, n + 1):
		r[i] = r[i >> 1] + r[i - (i >> 1) - 1] + i - 1
	return r
mins = compute_min(10 ** 5)
maxs = [i * (i - 1) // 2 for i in range(10 ** 5 + 1)]

def solvable(n, c):
	return mins[n] <= c <= maxs[n]

def solve(l, c):
	stack = [(l, c, 1)]
	result = []
	while stack:
		(n, c, offset) = stack.pop()
		c -= n - 1
		if n > 1:
			mid = n // 2
			pivot = search(1, mid + 1, lambda i: maxs[i] + maxs[n - i - 1] < c) - 1
			yield (offset + pivot)
			right = mins[n - pivot - 1]
			left = min(maxs[pivot], c - right)
			right = c - left
			stack.append((n - pivot - 1, right, pivot + offset + 1))
			stack.append((pivot, left, offset))
		elif n == 1:
			yield offset
q = int(input())
for _ in range(q):
	(l, c) = [int(x) for x in input().split()]
	if solvable(l, c):
		print(' '.join((str(x) for x in solve(l, c))))
	else:
		print('-1')


import math
import os
import random
import re
import sys
opt = [0] * (10 ** 5 + 1)
for i in range(1, 10 ** 5 + 1):
	opt[i] = i - 1 + opt[(i - 1) // 2] + opt[i // 2]

def optlist(n):
	if n <= 1:
		return [[], [0]][n]
	else:
		return [(n - 1) // 2] + optlist((n - 1) // 2) + [x + (n - 1) // 2 + 1 for x in optlist(n // 2)]

def lena(l):
	if len(l) <= 1:
		return 0
	else:
		return len(l) - 1 + lena([x for x in l[1:] if x < l[0]]) + lena([x for x in l[1:] if x > l[0]])

def lenasortinv(l, c):
	if c < opt[l] or c > l * (l - 1) // 2:
		return [-2]
	if c == opt[l]:
		return optlist(l)
	elif c == l * (l - 1) // 2:
		return list(range(l))[::-1]
	else:
		L = []
		while len(L) < l:
			j = 0
			k = l - len(L)
			while not opt[j] + opt[k - 1 - j] <= c - k + 1 <= j * (j - 1) // 2 + (k - 1 - j) * (k - 2 - j) // 2:
				j += 1
			while opt[j + 1] + opt[k - 2 - j] <= c - k + 1 <= j * (j + 1) // 2 + (k - 2 - j) * (k - 3 - j) // 2 and j + 1 < k // 2:
				j += 1
			if c - k + 1 >= j * (j - 1) // 2 + opt[k - 1 - j]:
				L += [len(L) + j - t for t in range(j + 1)]
				c -= k - 1 + j * (j - 1) // 2
			else:
				L += [len(L) + j] + [len(L) + x for x in optlist(j)]
				c -= k - 1 + opt[j]
		return L
q = int(input())
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	print(' '.join(map(lambda x: str(x + 1), lenasortinv(l, c))))


import math
import os
import random
import re
import sys

def lower_bound_table(n):
	min_arr = [0, 0]
	for i in range(2, n + 1):
		if i % 2 == 1:
			min_arr.append(i - 1 + 2 * min_arr[(i - 1) // 2])
		else:
			min_arr.append(i - 1 + min_arr[i // 2] + min_arr[i // 2 - 1])
	return min_arr

def upper_bound_table(n):
	max_arr = []
	for i in range(n + 1):
		max_arr.append(i * (i - 1) // 2)
	return max_arr

def comp_sort(arr):
	if len(arr) <= 1:
		return (arr, 0)
	counter = 0
	pivot = arr[0]
	arr1 = []
	arr2 = []
	for i in range(1, len(arr)):
		counter += 1
		if arr[i] < pivot:
			arr1.append(arr[i])
		elif arr[i] >= pivot:
			arr2.append(arr[i])
	(sorted1, counter1) = comp_sort(arr1)
	(sorted2, counter2) = comp_sort(arr2)
	return (sorted1 + [pivot] + sorted2, counter + counter1 + counter2)

def lena_sort(arr_len, comps, min_arr, max_arr):
	if arr_len == 0 and comps == 0:
		return []
	elif arr_len == 1 and comps == 0:
		return [1]
	elif arr_len == 2 and comps == 1:
		return [1, 2]
	elif comps > max_arr[arr_len] or comps < min_arr[arr_len]:
		return -1
	counter = 0
	while comps - (arr_len - 1) >= min_arr[arr_len - 1]:
		comps -= arr_len - 1
		arr_len -= 1
		counter += 1
		if arr_len == 2:
			return [i for i in range(1, counter + 2 + 1)]
	comps -= arr_len - 1
	r = (arr_len - 1) // 2
	s = arr_len - 1
	while r <= s:
		t = (r + s) // 2
		comps_min_1 = min_arr[t]
		comps_max_1 = max_arr[t]
		comps_min_2 = min_arr[arr_len - 1 - t]
		comps_max_2 = max_arr[arr_len - 1 - t]
		if comps_min_1 + comps_min_2 > comps:
			s = t - 1
		elif comps_max_1 + comps_max_2 < comps:
			r = t + 1
		else:
			break
	a = comps_min_1
	b = comps_max_1
	while a <= b:
		c = (a + b) // 2
		comps_rem = comps - c
		if comps_rem < comps_min_2:
			b = c - 1
		elif comps_rem > comps_max_2:
			a = c + 1
		else:
			break
	else:
		print('ERROR OCCURRED')
	arr1 = lena_sort(t, c, min_arr, max_arr)
	arr2 = lena_sort(arr_len - 1 - t, comps_rem, min_arr, max_arr)
	for i in range(len(arr1)):
		arr1[i] += counter
	for i in range(len(arr2)):
		arr2[i] += t + 1 + counter
	return [i for i in range(1, counter + 1)] + [t + 1 + counter] + arr1 + arr2
min_arr = lower_bound_table(100000)
max_arr = upper_bound_table(100000)
q = int(input())
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	arr_test = lena_sort(l, c, min_arr, max_arr)
	if arr_test == -1:
		print('-1')
	else:
		print(' '.join(list(map(str, arr_test))))


import math
import os
import random
import re
import sys
mns = [0, 0]
for i in range(2, 100001):
	mns.append(i - 1 + mns[i // 2] + mns[(i - 1) // 2])

def lena(length, comparisons):

	def mxs(x):
		return x * (x - 1) // 2
	if not mns[length] <= comparisons <= mxs(length):
		return -1
	result = [-1] * length
	stk = [(length, comparisons, 0, 1)]
	while stk:
		(length, comparisons, ofs, ofs2) = stk.pop()
		while length:
			comparisons -= length - 1
			for i in range(length):
				if mns[i] + mns[length - 1 - i] <= comparisons <= mxs(i) + mxs(length - 1 - i):
					c1 = min(max(comparisons, max(mns[i], comparisons - mxs(length - 1 - i))), min(mxs(i), comparisons - mns[length - 1 - i]))
					result[ofs] = i + ofs2
					if i:
						stk.append((i, c1, ofs + 1, ofs2))
					(length, comparisons, ofs, ofs2) = (length - i - 1, comparisons - c1, ofs + i + 1, ofs2 + i + 1)
					break
	return result
q = int(input())
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	res = lena(l, c)
	print(' '.join(map(str, res)) if res != -1 else -1)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(10 ** 6)
MIN_MAX_CACHE = [(0, 0), (0, 0), (1, 1)]

def find_min_max(l):
	if l >= len(MIN_MAX_CACHE):
		for i in range(len(MIN_MAX_CACHE), l + 1):
			l_1 = i - 1
			if l_1 % 2 == 0:
				value = (l_1 + find_min_max(l_1 // 2)[0] * 2, l_1 + find_min_max(l_1)[1])
			else:
				l_half = l_1 // 2
				value = (l_1 + (find_min_max(l_half)[0] + find_min_max(l_half + 1)[0]), l_1 + find_min_max(l_1)[1])
			MIN_MAX_CACHE.append(value)
	return MIN_MAX_CACHE[l]

def find_array(l, c, start=1):
	if l <= 1:
		if c == 0:
			return [start] * l
		else:
			raise Exception('No solution')
	if l == 2:
		if c == 1:
			return [start, start + 1]
		else:
			raise Exception('No solution')
	(min_, max_) = find_min_max(l)
	if not min_ <= c <= max_:
		raise Exception('No solution')
	if c == max_:
		return [i for i in range(start, start + l)]
	start_array = []
	sub_comparisons = c - l + 1
	(next_min, next_max) = find_min_max(l - 1)
	while sub_comparisons >= next_min:
		start_array.append(start)
		start += 1
		l -= 1
		c = sub_comparisons
		sub_comparisons = c - l + 1
		(next_min, next_max) = find_min_max(l - 1)
	for index in reversed(range(l // 2 + 1)):
		pivot = start + index
		higher_len = l - index - 1
		(higher_min, higher_max) = find_min_max(higher_len)
		(lower_min, lower_max) = find_min_max(index)
		if lower_min + higher_min <= sub_comparisons <= lower_max + higher_max:
			higher_comp = min(higher_max, sub_comparisons - lower_min)
			lower_comp = sub_comparisons - higher_comp
			return start_array + [pivot] + find_array(index, lower_comp, start) + find_array(higher_len, higher_comp, pivot + 1)
	else:
		raise Exception('No solution')
q = int(input())
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	try:
		print(*find_array(l, c))
	except:
		print(-1)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys

def compute_compares(arr):
	n = len(arr)
	if n == 0:
		return 0
	if n == 1:
		return 0
	if n == 2:
		return 1
	p = arr[0]
	l = []
	r = []
	for x in arr[1:]:
		if x < p:
			l.append(x)
		else:
			r.append(x)
	return n - 1 + compute_compares(l) + compute_compares(r)

def getMin(n, mins):
	l = len(mins)
	if n + 1 <= l:
		return mins
	for i in range(l, n + 1):
		if i - 1 & 1 == 0:
			mins.append(i - 1 + 2 * mins[(i - 1) // 2])
		else:
			mins.append(i - 1 + mins[(i - 1) // 2] + mins[(i - 1) // 2 + 1])
	return mins

def find_partition(n, c, mins):
	if n == 0:
		if c == 0:
			return []
		else:
			return -1
	if n == 1:
		if c == 0:
			return [1]
		else:
			return -1
	if n == 2:
		if c == 1:
			return [1, 2]
		else:
			return -1
	if n == 3:
		if c == 2:
			return [2, 1, 3]
		if c == 3:
			return [1, 2, 3]
		else:
			return -1
	if c < mins[n] or c > n * (n - 1) // 2:
		return -1
	if c == n * (n - 1) // 2:
		return list(range(1, n + 1))
	ll = 0
	rr = n - 1
	while ll <= rr:
		m = (ll + rr) // 2
		if c - (2 * n - m - 1) * m / 2 < mins[n - m]:
			rr = m - 1
		else:
			ll = m + 1
	if rr > 0:
		right_result = find_partition(n - rr, c - (2 * n - rr - 1) * rr / 2, mins)
		if right_result != -1:
			result = [x for x in range(1, rr + 1)] + [rr + x for x in right_result]
			return result
	new_c = c - (n - 1)
	l = 1
	r = (n + 1) // 2
	while l <= r:
		i = (l + r) // 2
		left_max = (i - 1) * (i - 2) // 2
		right_max = (n - i) * (n - i - 1) // 2
		if new_c <= left_max + right_max:
			l = i + 1
		else:
			r = i - 1
	left_max = (r - 1) * (r - 2) // 2
	right_max = (n - r) * (n - r - 1) // 2
	left_min = mins[r - 1]
	right_min = mins[n - r]
	d = left_max + right_max - new_c
	dr = max(0, left_min + d - left_max)
	dl = d - dr
	left_c = left_max - dl
	right_c = right_max - dr
	left_result = find_partition(r - 1, left_c, mins)
	if left_result == -1:
		return -1
	right_result = find_partition(n - r, right_c, mins)
	if right_result == -1:
		return -1
	right_result = [r + x for x in right_result]
	result = [r] + left_result + right_result
	return result

def reverseSort(l, c, mins):
	mx = l * (l - 1) // 2
	if c < mins[l] or c > mx:
		return ['-1']
	result = find_partition(l, c, mins)
	if result == -1:
		return ['-1']
	return [str(x) for x in result]
q = int(input())
sys.setrecursionlimit(100000000)
mins = [0, 0, 1]
for q_itr in range(q):
	lc = input().split()
	l = int(lc[0])
	c = int(lc[1])
	mins = getMin(l, mins)
	result = reverseSort(l, c, mins)
	print(' '.join(result))


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys

def worst_case(n):
	return n * (n - 1) // 2
BEST_CASE = {}

def best_case(n):
	if n in BEST_CASE:
		return BEST_CASE[n]
	if n == 0 or n == 1:
		BEST_CASE[n] = 0
		return 0
	result = n - 1 + best_case(n // 2) + best_case((n - 1) // 2)
	BEST_CASE[n] = result
	return result

def split_threshold(n):
	return n - 1 + worst_case((n - 1) // 2) + worst_case(n // 2)

def max(a, b):
	if a >= b:
		return a
	return b

def rig_list(n, desired_comps, first_val):
	if desired_comps < n - 1:
		return None
	worst = worst_case(n)
	if desired_comps > worst:
		return None
	if desired_comps >= split_threshold(n):
		arr = []
		for i in range(first_val, first_val + n):
			arr.append(i)
		desired_improvement = worst - desired_comps
		left_boundary = 0
		while desired_improvement > 0:
			swap_pos = max(n - 2 - desired_improvement, left_boundary)
			(arr[swap_pos], arr[swap_pos + 1]) = (arr[swap_pos + 1], arr[swap_pos])
			desired_improvement -= n - 2 - swap_pos
			left_boundary += 2
		return arr
	else:
		split_idx = n // 2
		split_val = first_val + split_idx
		size1 = split_idx
		worst_case1 = worst_case(size1)
		size2 = n - (split_idx + 1)
		worst_case2 = worst_case(size2)
		desired_improvement = n - 1 + worst_case1 + worst_case2 - desired_comps
		best_case2 = best_case(size2)
		desired_comps2 = max(worst_case2 - desired_improvement, best_case2)
		desired_comps1 = desired_comps - (n - 1) - desired_comps2
		sublist1 = rig_list(split_idx, desired_comps1, first_val)
		if sublist1 is None:
			return None
		sublist2 = rig_list(n - (split_idx + 1), desired_comps2, split_val + 1)
		if sublist2 is None:
			return None
		return [split_val] + sublist1 + sublist2
q = int(input().strip())
for q_itr in range(q):
	first_multiple_input = input().rstrip().split()
	l = int(first_multiple_input[0])
	c = int(first_multiple_input[1])
	result = rig_list(l, c, 1)
	if result is None:
		print('-1')
	else:
		for val in result:
			print(f'{val}', end=' ')
		print('')


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
from collections import deque
N = 100005
lower = [0] * N
upper = [0] * N
for i in range(2, N):
	lower[i] = lower[(i - 1) // 2] + lower[i - 1 - (i - 1) // 2] + i - 1
	upper[i] = upper[i - 1] + i - 1
	assert lower[i] <= upper[i]

def solve(n, c):
	ans = [0] * n
	q = deque()
	q.append([0, n - 1, c, 0])
	while q:
		(l, r, c, s) = q.popleft()
		n = r - l + 1
		i = 0
		j = n - 1
		x = c - n + 1
		found = False
		while not found and i <= j:
			if lower[i] + lower[j] <= x <= upper[i] + upper[j]:
				ans[l] = s + i
				ic = min(upper[i], x - lower[j])
				jc = x - ic
				if i > 0:
					q.append([l + 1, l + i, ic, s])
				if j > 0:
					q.append([l + i + 1, r, jc, s + i + 1])
				found = True
			i += 1
			j -= 1
		if not found:
			return []
	return ans
q = int(input().strip())
for q_itr in range(q):
	first_multiple_input = input().rstrip().split()
	n = int(first_multiple_input[0])
	c = int(first_multiple_input[1])
	if c < lower[n] or c > upper[n]:
		print(-1)
	else:
		ans = solve(n, c)
		if not ans:
			print(-1)
		else:
			ans = [x + 1 for x in ans]
			print(' '.join(map(str, ans)))


import math
import os
import random
import re
import sys

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)


import math
import os
import random
import re
import sys
sys.setrecursionlimit(100000)

def get_min_arr(length, start):
	if length == 0:
		return []
	if length == 1:
		return [0]
	memo = [(0, length)]
	while len(memo) < length:
		new_memo = []
		for m in memo:
			if isinstance(m, int):
				new_memo.append(m)
			else:
				(s, l) = m
				middle = s + (l - 1) // 2
				new_memo.append(middle)
				(s_less, l_less) = (s, (l - 1) // 2)
				(s_more, l_more) = (middle + 1, l // 2)
				if l_less == 1:
					new_memo.append(s_less)
				elif l_less > 1:
					new_memo.append((s_less, l_less))
				if l_more == 1:
					new_memo.append(s_more)
				elif l_more > 1:
					new_memo.append((s_more, l_more))
		memo = new_memo
	return [start + m for m in memo]

def rec(length, comparisons, first):
	if length == 0:
		return []
	if length == 1:
		return [first]
	prefix_length = 0
	remaining = length
	while True:
		tmp = remaining - 1
		if comparisons - tmp >= smallest[tmp]:
			prefix_length += 1
			comparisons -= tmp
			remaining = tmp
		else:
			break
	prefix = [first + p for p in range(prefix_length)]
	if prefix_length == length:
		return prefix
	length -= prefix_length
	comparisons -= remaining - 1
	first = first + prefix_length
	for less in range((length + 1) // 2):
		more = length - 1 - less
		(max_more, min_more) = (more * (more - 1) // 2, smallest[more])
		(max_less, min_less) = (less * (less - 1) // 2, smallest[less])
		lower = max(min_less, comparisons - max_more)
		upper = min(max_less, comparisons - min_more)
		if upper >= lower:
			break
	pivot = first + less
	if lower == comparisons - max_more:
		comparisons_less = lower
		A = rec(less, comparisons_less, first)
		B = list(range(pivot + 1, pivot + 1 + more))
	elif upper == comparisons - min_more:
		comparisons_less = upper
		A = rec(less, comparisons_less, first)
		B = get_min_arr(more, pivot + 1)
	else:
		comparisons_less = upper
		comparisons_more = comparisons - comparisons_less
		A = list(range(first, first + less))
		B = rec(more, comparisons_more, pivot + 1)
	return prefix + [pivot] + A + B
sys.setrecursionlimit(100000)
smallest = [0, 0]
q = int(input())
for q_itr in range(q):
	(l, c) = list(map(int, input().split()))
	for length in range(len(smallest), l + 1):
		if length % 2 == 0:
			s = smallest[length // 2 - 1] + smallest[length // 2]
		else:
			s = 2 * smallest[length // 2]
		smallest.append(s + length - 1)
	largest = l * (l - 1) // 2
	if c < smallest[l] or c > largest:
		result = '-1'
	else:
		arr = rec(l, c, 1)
		result = ' '.join(map(str, arr))
	print(result)