An array is said to be good if all its elements are distinct, i.e. no two elements of the array are equal to each other.

You are given a positive integer N and an integer K such that N ≤ K ≤ \binom{N+1}{2}.

Construct an array A of length N that satisfies the following conditions
A has exactly K good (contiguous) subarrays, and
Every element of A is an integer from 1 to N (both inclusive).

If there are multiple such arrays, you can print any of them.

Note: It can be shown that for all inputs satisfying the given constraints, there is always a valid solution.

------ Input Format ------ 

- The first line contains an integer T, the number of testcases. The description of the T testcases follow.
- Each testcase consists of a single line with two space separated integers, N and K respectively.

------ Output Format ------ 

- For each testcase print N space separated integers, the elements of the constructed array.
- If there are multiple outputs, you can print any of them.
- Your output will be considered correct only if the following conditions are satisfied,
- Every element of the array is between 1 and N, and
- The array has exactly K good subarrays

------ Constraints ------ 

$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 10^{5}$
$N ≤ K ≤ \binom{N+1}{2}$
- Sum of $N$ over all testcases is atmost $3 \cdot 10^{5}$.

----- Sample Input 1 ------ 
3
5 5
5 15
5 7
----- Sample Output 1 ------ 
1 1 1 1 1
1 2 3 4 5
1 2 2 1 1
----- explanation 1 ------ 
Test Case 1: $N = 5, K = 5$. All subarrays of length $1$ are good, therefore every array of size $N$ has at least $N$ good subarrays. If all elements are equal then these will be the only good subarrays so the given array $\{1, 1, 1, 1, 1\}$ is a valid solution. Observe that under the constraints there are $5$ different solutions (one for each value $1$ through $5$) and all of them will be considered correct.

Test Case 2: $N = 5, K = 15$. There are only $\binom{N + 1}{2} = 15$ subarrays, including the array itself. Therefore the array itself must be good which leads us to the solution given above. Any permutation of $\{1, 2, 3, 4, 5\}$ is also a valid solution, thus there are $5! = 120$ different solutions to this case and all of them will be considered correct.

Test Case 3: $N = 5, K = 7$. The constructed array is $A = \{1, 2, 2, 1, 1\}$. You may verify that the only good subarrays of $A$, in addition to the $5$ subarrays of length $1$, are those shown below (subarrays are highlighted red).
- $\{{\color{red}1}, {\color{red}2}, 2, 1, 1\}$
- $\{1, 2, {\color{red}2}, {\color{red}1}, 1\}$

Difficulty: HARD
Tags: Constructive algorithms

Starter code:

Solutions:
for _ in range(int(input())):
	(N, K) = [int(x) for x in input().split()]
	good = N
	A = [1]
	while good < K:
		good += len(A)
		A.append(A[-1] + 1)
	extra = good - K
	if extra > 0:
		A[-1] -= A[-1 - extra]
	while len(A) < N:
		A.append(A[-1])
	print(*A)


def solve(n, k):
	k -= n
	arr = []
	count = 0
	while k >= count:
		arr.append(count + 1)
		k -= count
		count += 1
	while len(arr) < n:
		arr.append(count - k)
	return arr
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = solve(n, k)
	print(*arr)


def solve(N, K):
	A = []
	(count, K) = (0, K - N)
	while K >= count:
		A.append(count + 1)
		K -= count
		count += 1
	while len(A) < N:
		A.append(count - K)
	print(*A)
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	solve(N, K)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(cnt, k) = (0, k - n)
	ans = []
	while k >= cnt:
		ans.append(cnt + 1)
		k -= cnt
		cnt += 1
	ans += [cnt - k] * (n - len(ans))
	print(*ans)


for _ in range(int(input())):
	(N, K) = [int(x) for x in input().split()]
	A = []
	K = K - N
	count = 0
	while K >= count:
		A.append(count + 1)
		K -= count
		count += 1
	while len(A) < N:
		A.append(count - K)
	print(*A)


import math
import bisect
from math import gcd, floor, sqrt, log
from collections import defaultdict as ddc
from collections import Counter
INF = 10 ** 20
mod = 1000000007

def MOD(p, q=1, mod=1000000007):
	expo = 0
	expo = mod - 2
	while expo:
		if expo & 1:
			p = p * q % mod
		q = q * q % mod
		expo >>= 1
	return p

def process(n, k):
	Ans = []
	(count, k) = (0, k - n)
	while k >= count:
		Ans.append(count + 1)
		k -= count
		count += 1
		print(Ans[-1], end=' ')
	while len(Ans) < n:
		Ans.append(count - k)
		print(Ans[-1], end=' ')
	print()

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		process(n, k)
main()


T = int(input())
for i in range(T):
	(n, k) = [int(X) for X in input().split()]
	t = 1
	while t * (t + 1) // 2 < k - (n - 1):
		t += 1
	val = (t - 1) * t // 2
	li = [1] * (n - t) + list(range(1, t + 1))
	if n - t >= 0 and n - t < n and (n - t + k - n - val >= 0) and (n - t + k - n - val < n):
		(li[n - t], li[n - t + k - n - val]) = (li[n - t + k - n - val], li[n - t])
	for z in li:
		print(z, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	m = n - 1
	ans = 0
	j = n * (n + 1)
	j = j // 2
	j = j - k
	while j >= m and j != 0:
		if j >= m:
			ans += 1
			j -= m
			m -= 1
	a = [0 for i in range(n)]
	a[0] = 1
	for i in range(1, ans + 1):
		a[i] = 1
	u = 0
	for i in range(n - 1, -1, -1):
		u += 1
		if u == j:
			a[i] = 1
	d = max(a) + 1
	for i in range(n):
		if a[i] != 1:
			a[i] = d
			d += 1
	print(*a[::-1])


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	if k == n:
		ans = [1] * n
	elif k == n * (n + 1) // 2:
		ans = [i for i in range(1, n + 1)]
	else:
		k -= n
		ans = []
		count = 0
		while k >= count:
			ans.append(count + 1)
			k -= count
			count += 1
		while len(ans) < n:
			ans.append(count - k)
	print(*ans)
	t -= 1


import math, bisect, heapq, random, sys, itertools
ints = lambda : list(map(int, input().split()))
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
p = 10 ** 9 + 7
pref = [0]
for i in range(1, 10 ** 6):
	pref.append(pref[-1] + i)
for t in range(int(input())):
	(n, k) = ints()
	arr = []
	for i in range(1, n + 1):
		if k - pref[i] >= n - i:
			arr.append(i)
			continue
		break
	k -= pref[len(arr)]
	left = n - len(arr)
	if left:
		k -= left - 1
		arr.append(arr[-k])
		for i in range(left - 1):
			arr.append(arr[-1])
	print(*arr)


T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	K = K - N
	count = 0
	A = []
	while count <= K:
		A.append(str(count + 1))
		K -= count
		count += 1
	while len(A) < N:
		A.append(str(count - K))
	print(' '.join(A))


t = int(input())
for _ in range(t):
	(n, k) = [int(s) for s in input().split(' ')]
	ans = []
	count = 0
	k = k - n
	while k >= count:
		ans.append(count + 1)
		k -= count
		count += 1
	while len(ans) < n:
		ans.append(count - k)
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = k - n
	(l, i) = ([], 0)
	while d - i >= 0:
		z = i + 1
		l.append(str(z))
		d = d - i
		i += 1
	while len(l) < n:
		z = i - d
		l.append(str(z))
	ans = ' '.join(l)
	print(ans)


def solve(n, k):
	count = 0
	K = k - n
	A = []
	while K >= count:
		A.append(count + 1)
		K -= count
		count += 1
	while len(A) < n:
		A.append(count - K)
	for i in A:
		print(i, end=' ')
	print()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	solve(n, k)


for t in range(int(input())):
	(n, k) = [int(c) for c in input().split()]
	x = 1
	while x <= n:
		if x * (x + 1) // 2 + (n - x) > k:
			break
		x += 1
	x -= 1
	rem = k - (x * (x + 1) // 2 + (n - x))
	ans = [i for i in range(1, x + 1)] + [x - rem] * (n - x)
	print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	arr.append(1)
	k -= n
	curr = 2
	for i in range(2, n + 1):
		if k < len(arr):
			val = arr[len(arr) - k - 1]
			arr.append(val)
			break
		k -= len(arr)
		arr.append(curr)
		curr += 1
	while len(arr) < n:
		arr.append(arr[-1])
	print(*arr, sep=' ')


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = []
	k = k - n
	cnt = 0
	while k >= cnt:
		A.append(cnt + 1)
		k -= cnt
		cnt += 1
	while len(A) < n:
		A.append(cnt - k)
	for ele in A:
		print(ele, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	(s, e) = (1, n)
	while s <= e:
		m = (s + e) // 2
		if m * (m + 1) // 2 + (n - m) > k:
			e = m - 1
		else:
			s = m + 1
	c = e * (e + 1) // 2 + n - e
	d = k - c
	ans = [1] * n
	for j in range(e):
		ans[e - 1 - j] = j + 1
	if d > 0:
		x = e
		while x < n:
			ans[x] = 1 + d
			x += 1
	for z in ans:
		print(z, end=' ')
	print()


import sys
input = sys.stdin.readline
T = int(input())

def testcase():
	(N, K) = map(int, input().split())
	(start, end) = (1, N)
	while start <= end:
		mid = (start + end) // 2
		if mid * (mid + 1) // 2 + (N - mid) > K:
			end = mid - 1
		else:
			start = mid + 1
	cnt = end * (end + 1) // 2 + N - end
	deficit = K - cnt
	sol = [1] * N
	for i in range(end):
		sol[end - 1 - i] = i + 1
	if deficit > 0:
		i = end
		while i < N:
			sol[i] = 1 + deficit
			i += 1
	for s in sol:
		print(s, end=' ')
	print('')
for _ in range(T):
	testcase()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	k = k - n
	c = 0
	l = []
	while k >= c:
		l.append(c + 1)
		k -= c
		c = c + 1
	while len(l) < n:
		l.append(c - k)
	print(*l)


def func():
	(n, k) = map(int, input().split())
	k = k - n
	if k == 0:
		print(*[1 for i in range(n)])
		return
	x = 1
	while k >= x * (x - 1) // 2:
		x += 1
	x -= 1
	arr = []
	for i in range(1, x + 1):
		arr.append(i)
	k -= x * (x - 1) // 2
	req_elem = arr[-(k + 1)]
	larr = len(arr)
	while larr < n:
		arr.append(req_elem)
		larr += 1
	print(*arr)
t = int(input())
for i in range(t):
	func()


t = int(input())
while t:
	(n, k) = map(int, input().split(' '))
	(ele, val, ls) = (0, 0, [])
	k -= n
	for i in range(n):
		if k - val >= 0:
			k -= val
			ele += 1
			val += 1
			ls.append(ele)
		elif k > 0:
			ele = ls[i - k - 1]
			k = 0
			ls.append(ele)
			val = 1
		else:
			ls.append(ele)
	print(' '.join([str(i) for i in ls]))
	t -= 1


from bisect import bisect_right as br
ss = [0] * 2 + list(range(1, 10 ** 5 + 1))
for i in range(2, 10 ** 5 + 2):
	ss[i] += ss[i - 1]
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	m = n * (n + 1) // 2
	if k == n:
		print(('1 ' * n).strip())
	elif k == m:
		print(' '.join(list(map(str, range(1, n + 1)))))
	else:
		rem = k - n
		ind = br(ss, rem)
		arr = list(range(1, ind)) + [ind - 1] * (n - ind + 1)
		off = rem - ss[ind - 1]
		arr = arr[:ind - 1] + [ind - 1 - off] * (n - ind + 1)
		print(' '.join(list(map(str, arr))))


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
gp = []
ans = []

def update_it(bit, i, val):
	n = len(bit)
	while i < n:
		bit[i] += val
		i += i & -i

def get_ans(bit, i):
	n = len(bit)
	tot = 0
	while i > 0:
		tot += bit[i]
		i -= i & -i
	return tot

def flip(a, l, r):
	for i in range(l, r):
		a[i] = '0' if a[i] == '1' else '1'
	return

def hnbhai(tc):
	(n, k) = sd()
	ans = []
	for i in range(n, 0, -1):
		if i * (i + 1) // 2 + (n - i) <= k:
			for j in range(i, 0, -1):
				ans.append(j)
			left = k - i * (i + 1) // 2 - (n - i)
			while len(ans) < n:
				ans.append(left + 1)
			print(*ans)
			return
for _ in range(sb()):
	hnbhai(_ + 1)


test = int(input())
while test:
	(n, k) = map(int, input().split())
	l = k - n
	a = []
	i = 1
	while l >= i * (i + 1) // 2:
		i += 1
	for j in range(1, i + 1):
		a.append(j)
	for j in range(n - i):
		a.insert(0, 1)
	num = l - i * (i - 1) // 2
	ipos = n - i
	p = a.pop(ipos)
	a.insert(ipos + num, 1)
	for m in a:
		print(m, end=' ')
	print()
	test -= 1


def solution():
	(N, K) = map(int, input().split())
	K -= N
	A = [1]
	for i in range(2, N + 1):
		if K < len(A):
			A.append(A[-(K + 1)])
			break
		K -= len(A)
		A.append(i)
	while len(A) < N:
		A.append(A[-1])
	print(*A)
for _ in range(int(input())):
	solution()


tcs = int(input())
while tcs:
	(n, k) = map(int, input().split())
	if n == k:
		print(*[1] * k)
	else:
		arr = [1] * 1
		k -= n
		curr = 2
		for i in range(2, n + 1):
			if k < len(arr):
				val = arr[len(arr) - (k + 1)]
				arr.append(val)
				break
			k -= len(arr)
			arr.append(curr)
			curr += 1
		while len(arr) < n:
			arr.append(arr[-1])
		print(*arr)
	tcs -= 1


import sys
RW = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
from collections import defaultdict as df
import heapq
from math import ceil, floor, log2
t = int(input())
for _ in range(t):
	(n, k) = RW()
	k -= n
	ans = [1] * n
	cur = 2
	i = 0
	add = 1
	while k - add >= 0:
		k -= add
		add += 1
		ans[i] = cur
		cur += 1
		i += 1
	for i in range(i + 1, n):
		if k == 0:
			break
		ans[i] = cur - k
	print(*ans)


import sys
RW = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
from collections import defaultdict as df
import heapq
from math import ceil, floor, log2
t = int(input())
for _ in range(t):
	(n, k) = RW()
	k -= n
	i = 0
	nxt = 1
	cur = 0
	while k >= cur:
		print(cur + 1, end=' ')
		i += 1
		k -= cur
		cur += 1
	while i < n:
		print(cur - k, end=' ')
		i += 1
	print()


import sys, os.path, math
if os.path.exists('Input.txt'):
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	Last = N * (N + 1) // 2
	if K == Last:
		print(*[i + 1 for i in range(N)])
	elif K < Last and N < K:
		(Series, Sum, Part) = (1, N, 0)
		for i in range(1, N + 1):
			if Sum + i <= K:
				Series += 1
				Sum += i
			else:
				Part = K - Sum
				break
		Answer = [i + 1 for i in range(1, Series)]
		if Part > 0:
			Answer.append(Series - Part)
		Left = N - len(Answer) + 1
		Answer = [1 for i in range(1, Left)] + Answer
		print(*Answer)
	else:
		print(*[1 for i in range(N)])


from math import sqrt
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = int(sqrt(2 * k))
	while n - s + s * (s + 1) // 2 > k:
		s -= 1
	arr = list(range(1, s + 1))
	size = len(arr)
	k -= s * (s + 1) // 2
	if k > 0:
		req = k - (n - size - 1)
		arr.append(arr[len(arr) - req])
		size += 1
		arr.extend([arr[-1]] * (n - size))
	print(*arr)


import math
import os
import random
import re
import sys
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	K -= N
	c = 2
	arr = [1]
	for i in range(1, N):
		if K < len(arr):
			d = arr[len(arr) - K - 1]
			arr.append(d)
			break
		K -= len(arr)
		arr.append(c)
		c += 1
	while len(arr) < N:
		arr.append(arr[len(arr) - 1])
	for i in range(len(arr)):
		print(arr[i], end=' ')
	print()


import sys

def input():
	return sys.stdin.readline().rstrip('\r\n')
(zr, on, tw) = (0, 1, 2)
tcs = int(input())
for tc in range(tcs):
	(n, k) = map(int, input().split())
	if n - k == zr:
		finn = [on] * k
		for i in range(len(finn)):
			print(finn[i], end=' ', flush=False)
		print()
	else:
		lis = [on] * on
		k -= n
		now = tw
		sz = len(lis)
		for i in range(tw, n + on):
			if k >= len(lis):
				pass
			else:
				tmp = lis[len(lis) - (k + on)]
				lis += [tmp]
				break
			k -= len(lis)
			lis += [now]
			now += on
		while True:
			if len(lis) >= n:
				break
			else:
				lis += [lis[-on]]
		for i in range(len(lis)):
			print(lis[i], end=' ', flush=False)
		print()


import bisect
import math
import string
from collections import deque, Counter
import sys
input = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7
dp = [[0] * 51 for i in range(51)]

def solve():
	(n, k) = map(int, input().split())
	ans = [1]
	k = k - n
	c = 2
	for i in range(2, n + 1):
		if k < len(ans):
			v = ans[len(ans) - k - 1]
			ans.append(v)
			break
		k = k - len(ans)
		ans.append(c)
		c = c + 1
	while len(ans) < n:
		ans.append(ans[-1])
	print(*ans)
for testis in range(int(input())):
	solve()


def calculation(n, p):
	maximum = n * (n + 1) // 2 + (n + 1)
	return min(maximum, n + p * (p - 1) // 2)

def compare(k, n, p):
	ans = calculation(n, p)
	return ans <= k

def search(n, k):
	x = 1
	y = n + 1
	index = y
	while index >= 1:
		while compare(k, n, x + index):
			x = x + index
		index = index // 2
	return x
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = search(n, k)
	steps = int(k - calculation(n, p))
	arr = [1 for _ in range(n)]
	i = int(n - p)
	c = 1
	while i < n:
		arr[i] = c
		i += 1
		c += 1
	c = int(n - p)
	i = 0
	while i < steps:
		(arr[c], arr[c + 1]) = (arr[c + 1], arr[c])
		i += 1
		c += 1
	print(*arr)


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	arr = []
	arr.append(1)
	k = k - n
	temp = 2
	for i in range(2, n + 1):
		if k < len(arr):
			rr = arr[len(arr) - k - 1]
			arr.append(rr)
			break
		k = k - len(arr)
		arr.append(temp)
		temp += 1
	while len(arr) < n:
		arr.append(arr[len(arr) - 1])
	print(*arr)


t = int(input())
for tc in range(t):
	(n, k) = map(int, input().split())
	it = 1
	bound = n
	if n == k:
		for i in range(n):
			print(1, end=' ')
		print()
		continue
	while k > bound:
		bound = bound + (n - it)
		it += 1
	newnum = it
	it -= 1
	arr = [1] * n
	for i in range(n):
		arr[i] = i % it + 1
	lb = bound - (n - it)
	diff = k - lb
	cnter = 0
	markers = []
	while diff > 0:
		if cnter == 0:
			for i in range(len(markers)):
				ind = markers[i]
				(arr[ind], arr[ind + 1]) = (arr[ind + 1], arr[ind])
				markers[i] = ind + 1
			arr[0] = newnum
			markers.append(0)
			cnter += 1
		else:
			for i in range(len(markers)):
				ind = markers[i]
				(arr[ind], arr[ind + 1]) = (arr[ind + 1], arr[ind])
				markers[i] = ind + 1
			cnter += 1
			cnter = cnter % newnum
		diff -= 1
	print(*arr)


from math import inf
from collections import *
import math, os, sys, heapq, bisect, random
from functools import lru_cache
from itertools import *

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def inpu():
	return int(inp())

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())
(M, M1) = (10 ** 9 + 7, 998244353)

def sieve(MAXN):
	prime = [True] * (MAXN + 10)
	(prime[0], prime[1]) = [False] * 2
	for i in range(2, int(math.sqrt(MAXN + 1)) + 5):
		if prime[i] == True:
			for j in range(i * i, MAXN + 5, i):
				prime[j] = False
	return prime

def main():
	how_much_noob_I_am = 1
	how_much_noob_I_am = inpu()
	for __ in range(how_much_noob_I_am):
		(n, k) = sep()
		k -= n
		arr = [1]
		curr = 2
		for i in range(2, n + 1):
			if len(arr) > k:
				val = arr[len(arr) - k - 1]
				arr.append(val)
				break
			k -= len(arr)
			arr.append(curr)
			curr += 1
		while len(arr) < n:
			arr.append(arr[-1])
		print(*arr)
main()


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	if k == n:
		ans = [1] * n
	elif k == n * (n + 1) // 2:
		ans = [i for i in range(1, n + 1)]
	else:
		k -= n
		ans = [1]
		c = 2
		for i in range(2, n + 1):
			if k < len(ans):
				x = ans[len(ans) - k - 1]
				ans.append(x)
				break
			k -= len(ans)
			ans.append(c)
			c += 1
		while len(ans) < n:
			x = ans[-1]
			ans.append(x)
	print(*ans)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	array = [1]
	k -= n
	right = 2
	for i in range(2, n + 1):
		if k < len(array):
			val = array[len(array) - k - 1]
			array.append(val)
			break
		k -= len(array)
		array.append(right)
		right += 1
	while len(array) < n:
		array.append(array[-1])
	for i in array:
		print(i, end=' ')
	print()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lst = [1]
	k -= n
	for i in range(2, n + 1):
		if k < len(lst):
			val = lst[len(lst) - k - 1]
			lst.append(val)
			break
		k -= len(lst)
		lst.append(i)
	while len(lst) < n:
		lst.append(lst[-1])
	print(*lst)


import math

def func():
	(n, k) = map(int, input().split())
	k -= n
	arr = [1]
	size = 1
	idx = 2
	for i in range(2, n + 1):
		if k < size:
			v = arr[size - k - 1]
			arr.append(v)
			size += 1
			break
		k -= size
		arr.append(idx)
		size += 1
		idx += 1
	while size < n:
		arr.append(arr[-1])
		size += 1
	print(*arr)
t = int(input())
for i in range(t):
	func()


def solve(n, k):
	a = [1]
	cur = 2
	k -= n
	for i in range(2, n + 1):
		if k < len(a):
			val = a[len(a) - k - 1]
			a.append(val)
			break
		k -= len(a)
		a.append(cur)
		cur += 1
	while len(a) < n:
		a.append(a[-1])
	for x in a:
		print(x, end=' ')
	print()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	solve(n, k)


try:
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		curr = n
		i = 1
		while curr < k:
			curr += i
			i += 1
		if curr > k:
			i -= 1
			curr -= i
		i -= 1
		A = [1] * (n - i)
		for j in range(i):
			A.append(j + 2)
		for x in range(k - curr):
			(A[n - i + x - 1], A[n - i + x]) = (A[n - i + x], A[n - i + x - 1])
		for x in A:
			print(x, end=' ')
		print()
except:
	pass


import math

def get_input(f):
	if f is None:
		nextline = input()
	else:
		nextline = f.readline()
	return nextline

def TOWERTOP():
	read_from_file = 0
	if read_from_file:
		f = open('input.txt', 'r')
	else:
		f = None
	for _ in range(int(get_input(f))):
		ins = list(map(int, get_input(f).split()))
		n = ins[0]
		k = ins[1]
		bucket = findBucket(n * (n + 1) / 2 - k + 1)
		numLetters = n + 1 - bucket
		maxPrevBucket = int(n * (n + 1) / 2 - bucket * (bucket + 1) / 2)
		posWithinbucket = k - maxPrevBucket
		maxLetterUsed = 0
		res = [0] * n
		nextLetter = (posWithinbucket - 1) % numLetters
		if nextLetter == 0:
			nextLetter = numLetters
		maxLetterNum = math.ceil(posWithinbucket / numLetters)
		maxLetterGone = False
		for i in range(n):
			res[i] = nextLetter
			if res[i] == numLetters:
				maxLetterUsed += 1
				if maxLetterUsed == maxLetterNum:
					maxLetterGone = True
			nextLetter -= 1
			if nextLetter == 0:
				nextLetter = numLetters
				if maxLetterGone:
					nextLetter -= 1
		print(' '.join(map(str, res)))

def findBucket(x):
	return math.ceil((-1 + math.sqrt(1 + 8 * x)) / 2)
TOWERTOP()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [1]
	k -= n
	curr = 2
	for i in range(2, n + 1):
		if k < len(a):
			val = a[len(a) - k - 1]
			a.append(val)
			break
		k -= len(a)
		a.append(curr)
		curr += 1
	while len(a) < n:
		a.append(a[-1])
	for i in a:
		print(i, end=' ')
	print()


def solve(n, k):
	a = [1]
	k -= n
	c = 2
	for i in range(2, n + 1):
		if k < len(a):
			v = a[len(a) - 1 - k]
			a.append(v)
			break
		k -= len(a)
		a.append(c)
		c += 1
	while len(a) < n:
		a.append(a[-1])
	return ' '.join((_ for _ in a))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = [1]
	k -= n
	c = 2
	for i in range(2, n + 1):
		if k < len(a):
			v = a[len(a) - 1 - k]
			a.append(v)
			break
		k -= len(a)
		a.append(c)
		c += 1
	while len(a) < n:
		a.append(a[-1])
	print(*a)


import math
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = 1
	b = 1
	c = -(2 * (k - n))
	x1 = (-b + (b * b - 4 * a * c) ** (1 / 2)) / 2
	x2 = (-b - (b * b - 4 * a * c) ** (1 / 2)) / 2
	p = 0
	if x1 > 0:
		p = math.ceil(x1)
	elif x2 > 0:
		p = math.ceil(x2)
	ap = p * (p + 1) // 2 + n
	ap1 = ap - k
	anslist = []
	if ap1 == 0:
		n1 = p + 1
	else:
		n1 = p
	for j in range(ap1 - 1):
		anslist.append(n1)
		n1 -= 1
	for j in range(n - ap1):
		if n1 >= 1:
			anslist.append(n1)
			n1 -= 1
		else:
			anslist.append(1)
	if ap1 != 0:
		anslist.insert(ap1 - 1, 1)
	print(*anslist[::-1])


import math

def func(N, K):
	itr = 2
	K -= N
	arr = [1]
	for i in range(2, N + 1):
		if K < len(arr):
			val = arr[len(arr) - K - 1]
			arr.append(val)
			break
		K -= len(arr)
		arr.append(itr)
		itr += 1
	while len(arr) < N:
		arr.append(arr[-1])
	return arr
	pass
T = int(input())
for i in range(T):
	(X, M) = map(int, input().split())
	print(*func(X, M))


import math
t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	li = []
	cnt = n
	for j in range(n):
		li.append(1)
	for j in range(1, n):
		if cnt + j <= k:
			li[j] = j + 1
			cnt += j
		else:
			u = k - cnt
			p = li[j - u - 1]
			for k in range(j, n):
				li[k] = p
			break
	for j in range(n):
		print(li[j], end=' ')
		if j == n - 1:
			print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [1] * 1
	k -= n
	curr = 2
	for x in range(2, n + 1):
		if k < len(l):
			val = l[len(l) - k - 1]
			l.append(val)
			break
		k -= len(l)
		l.append(curr)
		curr += 1
	while len(l) < n:
		l.append(l[-1])
	print(*l)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	k -= n
	d = 2
	arr = []
	arr.append(1)
	for i in range(2, n + 1):
		if k < len(arr):
			v1 = arr[len(arr) - k - 1]
			arr.append(v1)
			break
		k -= len(arr)
		arr.append(d)
		d += 1
	while len(arr) < n:
		arr.append(arr[len(arr) - 1])
	for i in arr:
		print(i, end=' ')
	print()


import math

def main():
	tc = int(input())
	while tc > 0:
		(n, k) = map(int, input().split())
		if k == n:
			for i in range(n):
				print('1', end=' ')
		else:
			diff = k - n
			sum = 1
			while sum * (sum + 1) <= 2 * diff:
				sum += 1
			sum -= 1
			if diff == (sum + 2) * (sum + 1) // 2 - 1:
				for i in range(n - sum - 1):
					print('1', end=' ')
				for i in range(sum):
					print(str(2 + i), end=' ')
				print('1')
			elif diff == sum * (sum + 1) // 2:
				for i in range(n - sum):
					print('1', end=' ')
				for i in range(sum):
					print(str(2 + i), end=' ')
			else:
				for i in range(n - sum - 1):
					print('1', end=' ')
				newdiff = int((sum + 2) * (sum + 1) / 2 - 1 - diff)
				for i in range(sum - newdiff):
					last = 2 + i
					print(str(2 + i), end=' ')
				print('1', end=' ')
				for i in range(newdiff):
					print(str(last + i + 1), end=' ')
		print()
		tc -= 1
main()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	max1 = n * (n + 1) // 2
	if k == n:
		A = [1 for i in range(n)]
	elif k == max1:
		A = [int(i) for i in range(1, n + 1)]
	else:
		for i in range(n - 1, 0, -1):
			if k >= max1 - i:
				A = [int(j) for j in range(1, i)]
				ref1 = k - (max1 - i)
				A1 = A[:i - ref1 - 1]
				A2 = A[i - ref1 - 1:]
				A1.append(i)
				A1 = A1 + A2
				n1 = n - i
				for j in range(n1):
					A1.append(i)
				A = A1
				break
			else:
				max1 -= i
	print(*A)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	if n == k:
		print(*[1] * n)
	else:
		x = k - n
		add = 0
		flip = 0
		for i in range(1, n + 1):
			sum = i * (i + 1) // 2
			if sum == x:
				add = i
				break
			elif sum > x:
				add = i - 1
				flip = x - (sum - i)
				break
		l = [1] * (n - add)
		for i in range(2, add + 2):
			l.append(i)
		if flip != 0:
			i = l.index(2)
			while flip > 0:
				(l[i], l[i - 1]) = (l[i - 1], l[i])
				i += 1
				flip -= 1
		print(*l)


def solver(n, k):
	i = 0
	diff = k - n
	while diff >= i * (i + 1) // 2:
		i += 1
	bucket = i
	index = diff - i * (i - 1) // 2
	arr = [j for j in range(2, bucket + 1)]
	arr.insert(index, 1)
	arr = [1 for _ in range(n - len(arr))] + arr
	s = [str(l) for l in arr]
	print(' '.join(s))
t = int(input())
while t > 0:
	t -= 1
	(n, k) = list(map(int, input().split(' ')))
	solver(n, k)


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k -= n
	c = 2
	arr = [1]
	ans = 0
	for i in range(2, n + 1):
		if k < len(arr):
			ans = arr[len(arr) - k - 1]
			arr.append(ans)
			break
		k -= len(arr)
		arr.append(c)
		c += 1
	while len(arr) < n:
		arr.append(arr[-1])
	print(*arr)


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	cur = 1
	num = [1]
	K -= 1
	second_part = []
	for i in range(1, N):
		if K > N - 1:
			num.append(i + 1)
			K -= i + 1
		else:
			repeat = K - (N - i - 1)
			second_part = [num[i - repeat] for _ in range(N - len(num))]
			break
	answer = num + second_part
	print(' '.join(list(map(str, answer))))


def ga():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, k) = ga()
	ans = [1 for i in range(n)]
	k -= n
	i = 1
	while i < n:
		if k >= i:
			ans[i] = ans[i - 1] + 1
			k -= i
		elif k == 0:
			ans[i] = ans[i - 1]
		else:
			ans[i] = ans[i - 1] - k
			k = 0
		i += 1
	ans = list(map(str, ans))
	print(' '.join(ans))


t = int(input())
for ti in range(t):
	(n, k) = [int(i) for i in input().split()]
	s = 0
	i = 0
	while i < n:
		s += n - i
		if s >= k:
			break
		i += 1
	s -= n - 1
	rem = k - s
	res = []
	for j in range(k - s + 1):
		res += (j % (i + 1) + 1,)
	if i > 0:
		rep = res[-i:]
		idx = 0
		for j in range(k - s + 1, n):
			res += (rep[idx % i],)
			idx += 1
	for r in res:
		print(r, end=' ')
	print()


from bisect import bisect_left, bisect_right
m = 100005
p2 = [0 for i in range(m)]
p2[m - 1] = m - 1
for i in range(m - 2, -1, -1):
	p2[i] = p2[i + 1] + i
p2 = p2[::-1]
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	y = k + p2[m - 1 - n - 1]
	ind = bisect_left(p2, y)
	df = 0
	if ind > m:
		ind -= 1
	if p2[ind] != y:
		df = y - p2[ind - 1]
	ind = m - 1 - ind
	arr = [0 for i in range(n)]
	num = n - ind + 1
	for i in range(num):
		arr[i] = i + 1
	if df == 0:
		j = 1
		for i in range(num, n):
			arr[i] = j
			if j + 1 > num:
				j = 1
			else:
				j = j + 1
	else:
		j = 1
		df -= 1
		for i in range(num, n):
			if df == 0:
				lst = i
				break
			arr[i] = j
			if j + 1 > num:
				j = 1
			else:
				j = j + 1
			df -= 1
		lft = lst - num + 1
		rgt = lst - 1
		j = lft
		for i in range(lst, n):
			arr[i] = arr[j]
			if j == rgt:
				j = lft
			else:
				j += 1
	print(*arr)


import math
t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	if k == n:
		for i in range(1, n + 1):
			print(1, end=' ')
		print('')
		continue
	if k == (n + 1) * (n + 2) // 2:
		for i in range(1, n + 1):
			print(i, end=' ')
		print('')
		continue
	k = k - n + 1
	x = -1 + math.sqrt(1 + 8 * k) / 2
	if x != int(x):
		x = int(x) + 1
	start = (x - 1) * x // 2 + 1
	final = x * (x + 1) // 2
	if k > final:
		x += 1
		start = (x - 1) * x // 2 + 1
		final = x * (x + 1) // 2
	for i in range(n - x):
		print(1, end=' ')
	for i in range(x):
		if k - start == i:
			print(1, end=' ')
		elif k - start < i:
			print(i + 1, end=' ')
		else:
			print(i + 2, end=' ')
	print('')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [1] * n
	i = 1
	while i * (i + 1) // 2 + i - 1 + n - i <= k:
		arr[i - 1] = i
		i += 1
	i = i - 1
	curr = i * (i + 1) // 2 + i - 1 + n - i
	if curr == k:
		print(*arr)
		continue
	i += 1
	arr[i - 1] = i
	p = i * (i + 1) // 2 + i - 1 + n - i - k
	(arr[p], arr[0]) = (arr[0], arr[p])
	print(*arr)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k - n
	if x == 0:
		print(*[1] * n)
	else:
		num = int(1 + math.sqrt(1 + 4 * 2 * x)) // 2
		val = int((math.pow(num, 2) - num) // 2)
		for i in range(1, num + 1):
			print(i, end=' ')
		rem = n - num
		for i in range(rem):
			print(num - x + val, end=' ')
		print()


import sys
import math
from collections import defaultdict, Counter
from bisect import *
from string import ascii_lowercase

def readInts():
	x = list(map(int, sys.stdin.readline().rstrip().split()))
	return x[0] if len(x) == 1 else x

def readList(type=int):
	x = sys.stdin.readline()
	x = list(map(type, x.rstrip('\n\r').split()))
	return x

def readStr():
	x = sys.stdin.readline().rstrip('\r\n')
	return x
write = sys.stdout.write
read = sys.stdin.readline

def solve():
	(n, k) = readInts()
	a = [1 for _ in range(n)]
	k -= n
	i = 2
	while (i + 1) * i / 2 - i < k:
		i += 1
	if (i + 1) * i / 2 - i > k:
		i -= 1
	k -= (i + 1) * i / 2 - i
	p = i
	for j in range(n - 1, n - i, -1):
		a[j] = p
		p -= 1
	if k:
		for j in range(n - i, n - i + int(k)):
			temp = a[j]
			a[j] = a[j + 1]
			a[j + 1] = temp
	print(*a)

def main():
	t = 1
	t = readInts()
	for _ in range(t):
		solve()
main()