Consider a permutation, $p_i$, of integers from $1$ to $n$. Let's determine the $distance$ of $p_i$ to be the minimum absolute difference between any $2$ consecutive integers in $p_i$: 
$distance(p_i)=\underset{0\le j<n-1}{\text{min}}\big|\ p_i[j]-p_i[j+1]\ |\ \text{if}\ n>1,\text{or}\ 0\ \text{if}\ n=1$

Generate a lexicographically sorted list of all permutations of length $n$ having a maximal distance between all permutations of the same length. Print the lexicographically $k^{th}$ permutation.

Input Format

The first line contains an integer, $\boldsymbol{\boldsymbol{t}}$ (the number of test cases).

The $\boldsymbol{\boldsymbol{t}}$ subsequent lines each contain two space-separated integers, $n_i$ (the permutation length) and $k_i$ (the 1-based index in the list of permutations having a maximal distance), respectively. The $i^{\mbox{th}}$ line corresponds to the $i^{\mbox{th}}$ test case. 

Note: It is guaranteed that the sum of all $n_i$ does not exceed $10^{6}$.

Constraints

$1\leq t\leq10$
$1\leq n_i\leq10^6$
$1\leq k_i\leq10^{18}$

Output Format

For each test case: if the list of permutations having maximal distance has at least $\boldsymbol{\mbox{k}}$ elements, print the $k^{th}$ permutation as sequential (i.e.: from $1$ to $n$) space-separated integers on a new line; otherwise, print $-1$.

Sample Input
3
3 5
4 2
4 3

Sample Output
3 1 2
3 1 4 2
-1

Explanation

For $n=3$ and $k=5$: 

$p_1=[1,2,3];distance(p_1)=min(~|1-2|,|2-3|~)=min(1,1)=1$ 

$p_2=[1,3,2];distance(p_2)=min(~|1-3|,|3-2|~)=min(2,1)=1$ 

$p_3=[2,1,3];distance(p_3)=min(~|2-1|,|1-3|~)=min(1,2)=1$ 

$p_4=[2,3,1];distance(p_4)=min(\:|2-3|,|3-1|\:)=min(1,2)=1$ 

$p_5=[3,1,2];distance(p_5)=min(~|3-1|,|1-2|~)=min(2,1)=1$ 

$p_6=[3,2,1];distance(p_6)=min(\:|3-2|,|2-1|\:)=min(1,1)=1$           

Each of the $\boldsymbol{6}$ permutations has distance $1$. We choose the fifth one (because $k=5$), and print 3 1 2 on a new line.

For $n=4$ and $k=2$: 

The maximal distance in the list of permutations of integers from $1$ to $\begin{array}{c}4\end{array}$ is $2$, and the only permutations having that distance are $P_{11}=[2,4,1,3]$ and $P_{14}=[3,1,4,2]$. We choose the second one (because $k=2$), and print 3 1 4 2 on a new line.

Source: hackerrank | Difficulty: HARD
Tags: Data structures


Solutions:
from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


import os
import sys
from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1
if 0:
	for k in range(7):
		print(naive(3, k))
	input()

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
if 1:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		perm = smart(n, k - 1)
		print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))


from bisect import *
import collections
from time import time
import random
popdistr = collections.Counter()

def naive(n, k):

	def gen(perm, nums):
		if len(perm) == n:
			perms.append(perm)
		for i in sorted(nums):
			if abs(perm[-1] - i) >= mindist:
				gen(perm + [i], nums - {i})
	perms = []
	mindist = n // 2
	for i in range(n):
		gen([i], set(range(n)) - {i})
	return perms[k] if k < len(perms) else -1

def smart(n, k):
	if n < 5:
		return naive(n, k)
	half = n // 2
	h = half
	H = half + 1
	if not n & 1:
		if k > 1:
			return -1
		perm = [None] * n
		if k == 0:
			perm[::2] = range(h - 1, -1, -1)
			perm[1::2] = range(n - 1, h - 1, -1)
		else:
			perm[::2] = range(h, n)
			perm[1::2] = range(h)
		return perm
	low = h + 3 << h - 2
	lowmid = 1 << h - 1
	if k >= (low + lowmid) * 2:
		return -1
	if k >= low + lowmid:
		merp = smart(n, (low + lowmid) * 2 - 1 - k)
		if merp == -2:
			return merp
		return [n - 1 - m for m in merp]
	if k >= low:
		return binary(list(range(n)), k - low, h)
	offset = [2]
	for i in range(half - 1):
		offset.append(offset[-1] * 2 + (1 << i))
		if offset[-1] > 10 ** 30:
			break
	offset.append(offset[-1] + (1 << i + 1))
	offset.append(0)
	nums = list(range(n))
	perm = []
	pops = 0
	while True:
		if k < 2:
			add = h + k
			return perm + [nums[i * add % n] for i in range(n)]
		i = bisect(offset, k)
		k -= offset[i - 1]
		if k >= offset[i - 1]:
			return perm + binary(nums, k - offset[i - 1], i)
		perm += (nums.pop(i), nums.pop(i + h - 1))
		n -= 2
		half -= 1
		h -= 1
		H -= 1
		if pops:
			popdistr[pops] -= 1
		pops += 1
		popdistr[pops] += 1

def binary(nums, k, i):
	n = len(nums)
	half = n // 2
	H = half + 1
	perm = [None] * n
	(ks, testbit) = (bin(k)[:1:-1], half - 1)
	(left, right) = (0, n - 1)
	for m in range(i, i + half):
		if testbit < len(ks) and ks[testbit] == '1':
			perm[right] = nums[m]
			perm[right - 1] = nums[(m + H) % n]
			right -= 2
		else:
			perm[left] = nums[m]
			perm[left + 1] = nums[(m + H) % n]
			left += 2
		testbit -= 1
	perm[left] = nums[i + half]
	return perm
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	perm = smart(n, k - 1)
	print(-1 if perm == -1 else ' '.join((str(p + 1) for p in perm)))