A permutation is a sequence of $n$ integers from $1$ to $n$, in which all the numbers occur exactly once. For example, $[1]$, $[3, 5, 2, 1, 4]$, $[1, 3, 2]$ are permutations, and $[2, 3, 2]$, $[4, 3, 1]$, $[0]$ are not.

Polycarp was given four integers $n$, $l$, $r$ ($1 \le l \le r \le n)$ and $s$ ($1 \le s \le \frac{n (n+1)}{2}$) and asked to find a permutation $p$ of numbers from $1$ to $n$ that satisfies the following condition:

$s = p_l + p_{l+1} + \ldots + p_r$.

For example, for $n=5$, $l=3$, $r=5$, and $s=8$, the following permutations are suitable (not all options are listed):

$p = [3, 4, 5, 2, 1]$;

$p = [5, 2, 4, 3, 1]$;

$p = [5, 2, 1, 3, 4]$.

But, for example, there is no permutation suitable for the condition above for $n=4$, $l=1$, $r=1$, and $s=5$.

Help Polycarp, for the given $n$, $l$, $r$, and $s$, find a permutation of numbers from $1$ to $n$ that fits the condition above. If there are several suitable permutations, print any of them.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 500$). Then $t$ test cases follow.

Each test case consist of one line with four integers $n$ ($1 \le n \le 500$), $l$ ($1 \le l \le n$), $r$ ($l \le r \le n$), $s$ ($1 \le s \le \frac{n (n+1)}{2}$).

It is guaranteed that the sum of $n$ for all input data sets does not exceed $500$.


-----Output-----

For each test case, output on a separate line:

$n$ integers — a permutation of length $n$ that fits the condition above if such a permutation exists;

-1, otherwise.

If there are several suitable permutations, print any of them.


-----Examples-----

Input
5
5 2 3 5
5 3 4 1
3 1 2 4
2 2 2 2
2 1 1 3
Output
1 2 3 4 5 
-1
1 3 2 
1 2 
-1


-----Note-----

None

Difficulty: MEDIUM_HARD
Tags: Complete search

Mathematics

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
from collections import defaultdict
for _ in ' ' * int(input()):
	(n, l, r, s) = map(int, input().split())
	(p, a, f) = ([], [0] * n, [0] * 100000)
	for i in range(1, n + 1):
		p.append(i)
	w = list(p[:r - l + 1])
	(b, h) = (sum(w), sum(p[-(r - l + 1):]))
	if not b <= s <= h:
		print(-1)
	else:
		c = s - b
		m = c % (r - l + 1)
		w[-1] = p[r - l] + c // (r - l + 1)
		for i in range(len(w) - 2, -1, -1):
			w[i] = w[i + 1] - 1
		for i in range(len(w) - 1, -1, -1):
			if not m:
				break
			m -= 1
			w[i] += 1
		for i in w:
			f[i] = 1
		for i in range(l, r + 1):
			a[i - 1] = w.pop()
		for i in range(n):
			if not a[i]:
				for j in range(len(p)):
					if f[p[j]] == 0:
						a[i] = p.pop(j)
						break
		print(*a)


for _ in range(int(input())):
	(n, l, r, s) = [int(x) for x in input().split()]
	diff = r - l + 1
	lal = diff - 1
	lala = lal * (lal + 1) // 2
	if s < diff * (diff + 1) // 2 or s > diff * n - lala:
		print(-1)
		continue
	main = [i for i in range(1, diff + 1)]
	sum = diff * (diff + 1) // 2
	main_diff = s - sum
	i = diff - 1
	ver = n
	while i >= 0:
		if main_diff + main[i] > ver:
			main_diff -= ver - main[i]
			main[i] = ver
			ver -= 1
			i -= 1
		else:
			main[i] += main_diff
			break
	j = 0
	el = 1
	for i in range(n):
		if i >= l - 1 and i <= r - 1:
			print(main[j], end=' ')
			j += 1
		else:
			while el in main:
				el += 1
			print(el, end=' ')
			el += 1
	print()


def solve(n, l, r, s):
	sol = list(range(1, r - l + 2))
	sol.reverse()
	somme = sum(sol)
	i = 0
	while somme < s:
		if i >= len(sol):
			print(-1)
			return
		if sol[i] < n and (i == 0 or sol[i] < sol[i - 1] - 1):
			sol[i] += 1
			somme += 1
		else:
			i += 1
	if somme < s or somme > s:
		print(-1)
		return
	reste = [x for x in range(1, n + 1) if x not in sol]
	result = reste[:l - 1] + sol + reste[l - 1:]
	print(*result)
t = int(input())
for i in range(t):
	(n, l, r, s) = list(map(int, input().split()))
	solve(n, l, r, s)


T = int(input())
for _ in range(T):
	(n, l, r, s) = [int(x) for x in input().split()]
	ma = (2 * n - r + l) * (r - l + 1) // 2
	mi = (2 - l + r) * (r - l + 1) // 2
	if s > ma or s < mi:
		print(-1)
	else:
		x = int((2 * s / (r - l + 1) + l - r) / 2)
		dad = s - int((2 * x + r - l) * (r - l + 1) / 2)
		arr = [0] * n
		for i in range(l - 1, r):
			arr[i] = x + (i - l + 1)
		cnt = 0
		for i in list(range(r - l + 1))[::-1]:
			add = min(n - cnt - arr[i + l - 1], dad)
			cnt += 1
			arr[i + l - 1] += add
			dad -= add
			if not dad:
				break
		sett = set(arr)
		cur = 1
		for i in range(0, l - 1):
			while cur in sett:
				cur += 1
			arr[i] = cur
			cur += 1
		for i in range(r, n):
			while cur in sett:
				cur += 1
			arr[i] = cur
			cur += 1
		print(' '.join([str(x) for x in arr]))


from sys import stdin
t = int(stdin.readline().strip())
for i in range(t):
	lst = [int(x) for x in stdin.readline().strip().split()]
	n = lst[0]
	l = lst[1]
	r = lst[2]
	s = lst[3]
	d = r - l + 1
	e = n - d
	if d * (d + 1) // 2 > s:
		print(-1)
		continue
	if n * (n + 1) // 2 - e * (e + 1) // 2 < s:
		print(-1)
		continue
	av = s // d
	missing = s - av * d
	liste = []
	halb = d // 2
	for k in range(halb):
		liste.append(av - halb + k)
	for k in range(halb):
		liste.append(av + k + 1)
	if d % 2 == 1:
		liste.insert(halb, av)
	result = [x + 1 for x in range(n)]
	if d % 2 == 0:
		for k in range((d - 1) // 2, -1, -1):
			if missing > 0:
				liste[k] += 1
				missing -= 1
	for k in range(len(liste) - 1, -1, -1):
		if missing > 0:
			liste[k] += 1
			missing -= 1
		del result[liste[k] - 1]
	for k in range(len(result)):
		if k + 1 == l:
			for elem in liste:
				print(elem, '', end='')
		print(result[k], '', end='')
	if r == n:
		for elem in liste:
			print(elem, '', end='')
	print()


for _ in ' ' * int(input()):
	(n, l, r, s) = map(int, input().split())
	(p, a, f) = ([], [0] * n, [0] * 5000)
	for i in range(1, n + 1):
		p.append(i)
	w = list(p[:r - l + 1])
	b = sum(w)
	if not b <= s <= sum(p[-(r - l + 1):]):
		print(-1)
	else:
		c = s - b
		m = c % (r - l + 1)
		w[-1] = p[r - l] + c // (r - l + 1)
		for i in range(len(w) - 2, -1, -1):
			w[i] = w[i + 1] - 1
		for i in range(len(w) - 1, -1, -1):
			if not m:
				break
			m -= 1
			w[i] += 1
		for i in range(l, r + 1):
			f[w[-1]] = 1
			a[i - 1] = w.pop()
		for i in range(n):
			if not a[i]:
				for j in range(n):
					if not f[p[j]]:
						a[i] = p.pop(j)
						break
		print(*a)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	z = r - l + 1
	p = 0
	q = 0
	i = 0
	b = list([i + 1 for i in range(n)])
	a = list(b[:z])
	while i < z:
		p = p + i + 1
		q = q + n - i
		i += 1
	c = s - p
	if s <= q and s >= p:
		i = -1
		while 1 > 0:
			if c == 0:
				break
			u = b[i] - a[i]
			if c > u:
				a[i] = b[i]
				c -= u
			else:
				a[i] = a[i] + c
				c = 0
			i -= 1
		for x in a:
			b.remove(x)
		b = b[:l - 1] + a + b[l - 1:]
		print(*(i for i in b))
	else:
		print(-1)


from collections import Counter

def solve(n, l, r, s):
	size = r - l + 1
	ini = size * (size + 1) // 2
	gap = s - ini
	if gap < 0:
		print(-1)
		return
	times = gap // size
	if times + size > n:
		print(-1)
		return
	li = [times + i + 1 for i in range(size)]
	gap -= times * size
	for i in range(size - 1, size - gap - 1, -1):
		li[i] += 1
	C = Counter(li)
	emp = []
	for i in range(1, n + 1):
		if C[i] == 0:
			emp.append(i)
	ans = emp[:l - 1] + li + emp[l - 1:]
	for it in ans:
		if it > n:
			print(-1)
			return
	print(*ans)
for case in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	solve(n, l, r, s)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	z = r - l + 1
	m = 0
	t = 0
	temp = n - z + 1
	while t < z:
		m += n - t
		t += 1
	mi = z * (z + 1) // 2
	if s >= mi and s <= m:
		a = []
		v = []
		for i in range(n):
			v.append(0)
		for i in range(1, n + 1):
			if s - i <= m - temp:
				a.append(i)
				s -= i
				m -= temp
				temp += 1
				v[i - 1] = 1
		j = 0
		for i in range(l - 1):
			while v[j] == 1:
				j += 1
			print(j + 1, end=' ')
			j += 1
		print(*a, end=' ')
		for i in range(r, n):
			while v[j] == 1:
				j += 1
			print(j + 1, end=' ')
			j += 1
		print()
	else:
		print(-1)


def Low(k):
	return k * (k + 1) // 2

def High(n, k):
	return k * (2 * n - k + 1) // 2
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	(r, l) = (r - 1, l - 1)
	if not High(n, k) >= s >= Low(k):
		print(-1)
		continue
	L = [0] * n
	(lp, rp) = (l, l - 1)
	for i in range(n, 0, -1):
		if High(i, k) >= s and s - i >= Low(k - 1) and k:
			L[lp] = i
			lp += 1
			s -= i
			k -= 1
		else:
			L[rp] = i
			rp -= 1
	if k:
		print(-1)
	else:
		print(*L)


t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	d = r - l + 1
	k = n - d
	mini = d * (d + 1) // 2
	maxi = d * n - d * (d - 1) // 2
	if s not in range(mini, maxi + 1):
		print(-1)
		continue
	if k == 0:
		print(' '.join(map(str, range(1, n + 1))))
		continue
	i = s - mini
	rr = i // k
	ll = d - rr
	c = ll + i % k
	T = list(range(1, ll)) + ([c] if s != maxi else []) + list(range(n - rr + 1, n + 1))
	Tt = list(range(ll, c)) + list(range(c + 1, n - rr + 1))
	TT = Tt[:l - 1] + T + Tt[l - 1:]
	print(' '.join(map(str, TT)))


t = int(input())
for _ in range(t):
	(n, l, r, s) = [int(i) for i in input().split()]
	arr = [-1 for i in range(n)]
	l -= 1
	r -= 1
	fill = r - l + 1
	max_possi = 0
	m = n
	for i in range(fill):
		max_possi += m
		m -= 1
	min_possi = fill * (fill + 1) // 2
	if s > max_possi or s < min_possi:
		print(-1)
	else:
		m = n
		for i in range(r, l - 1, -1):
			arr[i] = m
			m -= 1
		rem = max_possi - s
		start = 1
		for i in range(l, r + 1):
			if rem == 0:
				break
			avail = arr[i] - start
			if rem >= avail:
				rem -= avail
				arr[i] = start
			else:
				avail -= rem
				arr[i] = start + avail
				rem = 0
			start += 1
		visited = [0] * (n + 1)
		for i in range(l, r + 1):
			visited[arr[i]] = 1
		available = []
		for i in range(1, n + 1):
			if visited[i] == 0:
				available.append(i)
		for i in range(l):
			arr[i] = available.pop(0)
		for i in range(r + 1, n):
			arr[i] = available.pop(0)
		print(*arr)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	y = sum(range(n - x + 1, n + 1))
	z = sum(range(1, x + 1))
	if s > y or s < z:
		print(-1)
	else:
		j = n - x + 1
		arr = set()
		for i in range(1, n + 1):
			if y - j + i >= s:
				arr.add(i)
				y -= j
				y += i
				j += 1
		s1 = {*range(1, n + 1)} - arr
		ans = list(s1)[:l - 1] + list(arr) + list(s1)[l - 1:]
		print(*ans)


def gauss(a, b):
	return (a + b) * (b - a + 1) // 2
for t in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	s2 = s
	cnt = r - l + 1
	taken = set()
	for i in range(1, cnt + 1):
		for j in range(n - i + 1, 0, -1):
			if gauss(1, cnt - i) + j <= s:
				taken.add(j)
				s -= j
				break
		else:
			s -= 921021581234050283
	rest = list(set(range(1, n + 1)) - taken)
	if s == 0 and sum(taken) == s2:
		print(*rest[:l - 1], *taken, *rest[l - 1:])
	else:
		print('-1')


import sys
sr = lambda : input()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
import bisect
from sys import stdout
inf = 10 ** 18
mod = 998244353
import random
test = int(input())
for t in range(test):
	(n, l, r, s) = map(int, input().split())
	m = r - l + 1
	l_max = n - m + 1
	r_min = m
	if s > (l_max + n) * m // 2 or s < (1 + r_min) * m // 2:
		print(-1)
	else:
		cand = []
		for r_now in range(r_min, n + 1):
			l_now = r_now - m + 1
			cand.append((l_now + r_now) * m // 2)
		ind = bisect.bisect_left(cand, s)
		if cand[ind] == s:
			ans_r = m + ind
			ans_l = ans_r - m + 1
			ans = [0 for i in range(n)]
			now = 1
			for i in range(n):
				if now == ans_l:
					now = ans_r + 1
				if i < l - 1:
					ans[i] = now
					now += 1
				elif l - 1 <= i <= r - 1:
					ans[i] = ans_l + i - (l - 1)
				else:
					ans[i] = now
					now += 1
			print(*ans, sep=' ')
		else:
			tmp = cand[ind] - s
			ans_r = m + ind
			ans_l = ans_r - m + 1
			rem = ans_l + tmp - 1
			ans_l -= 1
			ans = [0 for i in range(n)]
			now = 1
			flg = True
			for i in range(n):
				if flg:
					if ans_l <= now <= ans_r:
						now = ans_r + 1
				elif ans_l - 1 <= now <= ans_r:
					now = ans_r + 1
				if i < l - 1:
					ans[i] = now
					now += 1
				elif l - 1 <= i <= r - 1:
					if ans_l + i - (l - 1) != rem:
						ans[i] = ans_l + i - (l - 1)
					else:
						ans[i] = ans_l + 1 + i - (l - 1)
						ans_l += 1
						flg = False
				else:
					ans[i] = now
					now += 1
			for i in range(n):
				if ans[i] == n + 1:
					ans[i] = rem
			print(*ans, sep=' ')


t = int(input())
for z in range(t):
	(n, l, r, s) = map(int, input().split())
	p = r - l + 1
	mn = p * (p + 1) // 2
	mx = n * (n + 1) // 2 - (n - p) * (n - p + 1) // 2
	if s < mn or s > mx:
		print(-1)
	else:
		brr = []
		for i in range(p, 0, -1):
			brr.append(i)
		k = s - mn
		i = 0
		while k:
			brr[i % len(brr)] += 1
			k = k - 1
			i = i + 1
		arr = [0] * n
		arr[l - 1:r] = brr
		p = 0
		for i in range(1, n + 1):
			if i not in arr:
				if p == l - 1:
					p = r
				arr[p] = i
				p = p + 1
		print(*arr)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	l -= 1
	r -= 1
	x = r - l + 1
	a = [n - i for i in range(x)]
	temps = sum(a)
	if temps < s:
		print(-1)
		continue
	elif temps == s:
		b = [0] * n
		j = 1
		for i in range(n):
			if i >= l and i <= r:
				b[i] = a[i - l]
			else:
				b[i] = j
				j += 1
		print(*b)
		continue
	else:
		d = temps - s
		a.reverse()
		m = 1
		for i in range(x):
			if d != 0:
				num2 = max(m, a[i] - d)
				d -= a[i] - num2
				a[i] = num2
				m += 1
			else:
				break
		if d != 0:
			print(-1)
			continue
		b = [0] * n
		c = [i + 1 for i in range(n)]
		for num in a:
			c.remove(num)
		j = 0
		for i in range(n):
			if i >= l and i <= r:
				b[i] = a[i - l]
			else:
				b[i] = c[j]
				j += 1
		print(*b)


from collections import Counter
tc = int(input())
for _ in range(tc):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	if s >= k * (k + 1) // 2 and s <= n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2:
		t = [i + (s - k * (k + 1) // 2) // k for i in range(1, k + 1)]
		su = sum(t)
		pp = k - 1
		while su < s:
			t[pp] += 1
			su += 1
			if pp == 0:
				pp = k - 1
			else:
				pp -= 1
		rr = set(range(1, n + 1)) - set(t)
		ans = [0 for i in range(n)]
		for i in range(n):
			if i <= r - 1 and i >= l - 1:
				ans[i] = t[i - r + 1]
			else:
				ans[i] = rr.pop()
		print(*ans)
	else:
		print(-1)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, l, r, s) = map(int, sys.stdin.readline().split())
	k = r - l + 1
	(low_sum, high_sum) = (sum(range(1, k + 1)), sum(range(n - k + 1, n + 1)))
	if s < low_sum or high_sum < s:
		print(-1)
		continue
	(idx, limit) = (k, n)
	temp = [i for i in range(k + 1)]
	while sum(temp) != s:
		temp[idx] += 1
		if temp[idx] == limit:
			idx -= 1
			limit -= 1
	(ans, idx, num) = ([], 1, 1)
	for i in range(1, n + 1):
		if l <= i <= r:
			ans.append(temp[idx])
			idx += 1
			continue
		while num in temp:
			num += 1
		ans.append(num)
		num += 1
	print(*ans)


def high(i, k):
	return k * (2 * i + 1 - k) // 2

def low(k):
	return k * (k + 1) // 2
for z in range(int(input())):
	(n, le, r, s) = map(int, input().split())
	s2 = s
	k = r - le + 1
	l = []
	for i in range(n, 0, -1):
		if k > 0 and high(i, k) >= s and (s - i >= low(k - 1)):
			s -= i
			l.append(i)
			k -= 1
		if k == 0:
			break
	if sum(l) != s2:
		print(-1)
	else:
		c = [0] * (n + 1)
		for i in range(len(l)):
			c[l[i]] += 1
		co = 0
		i = 1
		while co < le - 1:
			if c[i] == 0:
				print(i, end=' ')
				co += 1
			i += 1
		for x in range(len(l)):
			print(l[x], end=' ')
		co = r
		while co < n:
			if c[i] == 0:
				print(i, end=' ')
				co += 1
			i += 1
		print()


import math
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop

def solve():
	(n, l, r, tar) = map(int, input().split())
	l -= 1
	ans = [0 for i in range(n)]
	req = [i for i in range(1, r - l + 1)]
	s = sum(req)
	if s > tar:
		print(-1)
		return
	c = 0
	for i in range(len(req) - 1, -1, -1):
		add = min(n - c - req[i], tar - s)
		req[i] += add
		s += add
		c += 1
		if tar == s:
			break
	if s != tar:
		print(-1)
		return
	i = j = 0
	num = 1
	used = set(req)
	while i < n:
		if i < l or i >= r:
			if num not in used:
				ans[i] = num
				i += 1
				num += 1
			else:
				num += 1
		else:
			ans[i] = req[j]
			j += 1
			i += 1
	if len(set(ans)) == n and sum(ans[l:r]) == tar:
		print(*ans)
t = 1
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	rem = set()
	out = []
	for i in range(n, 0, -1):
		low = k * (k - 1) // 2
		high = k * (2 * i - k + 1) // 2
		if k and high >= s and (s - i >= low):
			out.append(i)
			s -= i
			k -= 1
		else:
			rem.add(i)
	if s == 0:
		left = []
		right = []
		i = 1
		for num in rem:
			if i < l:
				left.append(num)
				i += 1
			else:
				right.append(num)
		out = left + out + right
		print(*out)
	else:
		print(-1)


import sys

def solve(n, l, r, s):
	l -= 1
	r -= 1
	ll = r - l + 1
	if s > (n + n - ll + 1) * ll // 2 or s < (1 + ll) * ll // 2:
		print(-1)
	else:
		ans = [None] * n
		arr = list(range(1, n + 1))
		p_sum = sum(arr[:ll])
		found = False
		for i in range(ll, n):
			if p_sum <= s < p_sum + ll:
				found = True
				tmp = arr[i - ll:i]
				if s > p_sum:
					tmp.remove(arr[i] - (s - p_sum))
					tmp.append(arr[i])
				break
			p_sum += arr[i]
			p_sum -= arr[i - ll]
		if not found:
			if p_sum == s:
				tmp = arr[n - ll:]
		ans[l:r + 1] = tmp.copy()
		t = set(tmp)
		j = 0
		for i in range(1, n + 1):
			if i not in t:
				while j < n and ans[j] != None:
					j += 1
				ans[j] = i
		print(*ans)
T = int(input())
for t in range(T):
	(n, l, r, s) = map(int, input().split())
	solve(n, l, r, s)


t = int(input())
for _ in range(t):

	def solve():
		(n, l, r, s) = map(int, input().split())
		sz = r - l + 1
		lb = n - sz + 1

		def cal(x, y):
			return (x + y) * (y - x + 1) // 2
		if cal(1, sz) <= s and s <= cal(lb, n):
			(ans, vis) = ([0] * n, [False] * (n + 1))
			(now, left) = (n, sz)
			for i in range(l - 1, r):
				while now + cal(1, left - 1) > s:
					now -= 1
				ans[i] = now
				s -= now
				vis[now] = True
				now -= 1
				left -= 1
			now = 1
			for i in range(n):
				if ans[i]:
					continue
				while vis[now]:
					now += 1
				ans[i] = now
				vis[now] = True
			print(' '.join((str(x) for x in ans)))
		else:
			print(-1)
	solve()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	ct = r - l + 1
	a = list(range(1, ct + 1))
	high = n
	sm = sum(a)
	if sm > s:
		print(-1)
		continue
	for j in range(ct - 1, -1, -1):
		if sm == s:
			break
		s1 = sm - a[j]
		cand = min(high, s - s1)
		a[j] = cand
		high = cand - 1
		sm = s1 + cand
	if sm != s:
		print(-1)
	else:
		nums = [d for d in range(1, n + 1) if d not in a]
		res = []
		while len(res) < n:
			if a and len(res) + 1 >= l:
				res.append(a.pop(0))
			else:
				res.append(nums.pop(0))
		print(' '.join(map(str, res)))


t = int(input())
for i in range(t):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	st = 0
	en = 0
	sub = []
	dic = {}
	suff = []
	for i in range(1, x + 1):
		st += i
		sub.append(i)
		en += n - i + 1
	if s >= st and s <= en:
		diff = s - st
		a = diff // x
		b = diff % x
		for i in range(x - 1, -1, -1):
			sub[i] += a
			if b > 0:
				sub[i] += 1
				b -= 1
		for i in sub:
			dic[i] = 1
		y = r
		for i in range(1, n + 1):
			if y < n:
				if i in dic:
					continue
				else:
					sub.append(i)
					dic[i] = 1
					y += 1
		y = 0
		for i in range(1, n + 1):
			if y < l:
				if i in dic:
					continue
				else:
					suff.append(i)
					dic[i] = 1
					y += 1
		ans = suff + sub
		print(*ans)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	(n, l, r, s) = list(map(int, input().split()))
	k = r - l + 1
	max_sum = k * (2 * n + 1 - k) // 2
	min_sum = k * (k + 1) // 2
	if s > max_sum or s < min_sum:
		print(-1)
	else:
		a = []
		b = []
		for i in range(n, 0, -1):
			if k > 0 and k * (2 * i + 1 - k) // 2 >= s and (s - i >= (k - 1) * k // 2):
				b.append(i)
				k = k - 1
				s = s - i
			else:
				a.append(i)
		if s > 0:
			print(-1)
		else:
			for i in b:
				a.insert(l - 1, i)
				l += 1
		print(*a)


import sys
import math
from math import factorial, inf, gcd
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 5)

def rarray():
	return [int(i) for i in input().split()]
ti = 1
ti = int(input())
for ii in range(ti):
	(n, l, r, s) = rarray()
	ans = []
	f = [False] * (n + 1)
	m = r - l + 1
	for i in reversed(range(1, n + 1)):
		if s - i >= (1 + m - 1) * (m - 1) // 2 and i >= m:
			ans.append(i)
			f[i] = True
			s -= i
			m -= 1
	if s > 0 or m < 0:
		print(-1)
		continue
	res = []
	for i in range(1, n + 1):
		if not f[i]:
			res.append(i)
	k1 = k2 = 0
	for i in range(1, n + 1):
		if l <= i <= r:
			print(ans[k2], end=' ')
			k2 += 1
		else:
			print(res[k1], end=' ')
			k1 += 1
	print()


from collections import Counter as C

def fun(s, k, n):
	l = [i + 1 for i in range(k)]
	ss = k * (k + 1) // 2
	if ss > s:
		print(-1)
		return [-1]
	x = s - ss
	z = x // k
	for i in range(k):
		l[i] += z
		if l[i] > n:
			print(-1)
			return [-1]
	for i in range(k - 1, k - x % k - 1, -1):
		l[i] += 1
		if l[i] > n:
			print(-1)
			return [-1]
	return l

def funn(n, l, r, s):
	a = fun(s, r - l + 1, n)
	if a[0] == -1:
		return
	x = [0] * 502
	for i in range(len(a)):
		x[a[i]] += 1
	z = 1
	for i in range(l - 1):
		while x[z] == 1:
			z += 1
		print(z, end=' ')
		x[z] += 1
	for i in range(len(a)):
		print(a[i], end=' ')
	for i in range(r, n):
		while x[z] == 1:
			z += 1
		print(z, end=' ')
		x[z] += 1
	print()
	return
for _____ in range(int(input().strip())):
	(n, l, r, s) = map(int, input().split())
	funn(n, l, r, s)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	w = r - l + 1
	m = sum(range(n, n - w, -1))
	if s > m or s < sum(range(1, w + 1)):
		print(-1)
		continue
	j = n - w + 1
	arr = set()
	for i in range(1, n + 1):
		if m - j + i >= s:
			arr.add(i)
			m -= j
			m += i
			j += 1
	s1 = {*range(1, n + 1)} - arr
	ans = list(s1)[:l - 1] + list(arr) + list(s1)[l - 1:]
	print(*ans)


import sys
N = int(200000.0 + 5)
sys.setrecursionlimit(N)

def charming():
	(n, l, r, s) = map(int, input().split())
	len = r - l + 1

	def cal(l, r) -> int:
		return (r - l + 1) * (r + l) // 2
	if cal(n - len + 1, n) < s or cal(1, len) > s:
		print(-1)
		return
	cur = n
	used = set()
	ans = [0] * (n + 1)
	for i in range(l, r + 1):
		while cur + cal(1, r - i) > s:
			cur -= 1
		s -= cur
		ans[i] = cur
		used.add(cur)
		cur -= 1
	cur = 1
	for i in range(1, n + 1):
		while cur in used:
			cur += 1
		if ans[i]:
			continue
		ans[i] = cur
		cur += 1
	for i in range(1, n + 1):
		print(ans[i], end=' ')
	print()
for t in range(int(input())):
	charming()


t = int(input())
for _ in range(t):
	(n, l, r, s) = list(map(int, input().split()))
	d = r - l + 1
	mi = d * (d + 1) // 2
	ma = sum((n - x for x in range(d)))
	if not mi <= s <= ma:
		print(-1)
		continue
	offset = 0
	current = [x + 1 for x in range(d)][::-1]
	i = 0
	while sum(current) < s and i < d:
		dif = s - sum(current)
		ne = min(n - offset, current[i] + dif)
		current[i] = ne
		i += 1
		offset += 1
	out = [0] * n
	avail = {x for x in range(1, n + 1)}
	avail = list(avail.difference(set(current)))
	out[l - 1:r] = current
	curr = 0
	for (i, x) in enumerate(out):
		if x == 0:
			out[i] = avail[curr]
			curr += 1
	print(*out)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	subarr = [i for i in range(1, r - l + 2)]
	if s > len(subarr) * (2 * n - len(subarr) + 1) // 2 or s < len(subarr) * (len(subarr) + 1) // 2:
		print(-1)
		continue
	minsum = (r - l + 1) * (r - l + 2) // 2
	diff = s - minsum
	marked = [0 for i in range(501)]
	for i in range(len(subarr)):
		subarr[i] = subarr[i] + diff // len(subarr)
		marked[subarr[i]] = 1
	for i in range(diff % len(subarr)):
		marked[subarr[len(subarr) - 1 - i]] = 0
		subarr[len(subarr) - 1 - i] += 1
		marked[subarr[len(subarr) - 1 - i]] = 1
	ans = []
	i = 1
	ele = 0
	while ele < l - 1:
		if marked[i] == 0:
			ans.append(i)
			ele += 1
		i += 1
	ans.extend(subarr)
	ele = 0
	while ele < n - r:
		if marked[i] == 0:
			ans.append(i)
			ele += 1
		i += 1
	print(*ans)


for _ in range(int(input())):
	(n, l, r, total) = map(int, input().split())
	(mini, maxi, a, b) = (0, 0, 1, n)
	s = total
	for i in range(l - 1, r):
		mini += a
		maxi += b
		b -= 1
		a += 1
	if total > maxi or total < mini:
		print(-1)
		continue
	a = [i for i in range(1, n + 1)]
	stack = []
	length = r - l + 1
	now = True
	for i in range(l - 1, r):
		if i == r - 1:
			sumleft = total - sum(stack)
			if sumleft in a:
				stack.append(sumleft)
				a.remove(sumleft)
			else:
				now = False
		else:
			for j in range(len(a) - 1, -1, -1):
				ele = a[j]
				tmp = length - len(stack) - 1
				val = tmp * (tmp + 1) // 2
				if total - sum(stack) - ele >= val:
					stack.append(ele)
					a.remove(ele)
					break
		if len(stack) != i - (l - 1) + 1:
			now = False
	if now == False:
		print(-1)
		continue
	ans = [-1] * n
	pos = 0
	for i in range(l - 1):
		ans[i] = a[pos]
		pos += 1
	for i in range(r, n):
		ans[i] = a[pos]
		pos += 1
	pos = 0
	for i in range(l - 1, r):
		ans[i] = stack[pos]
		pos += 1
	print(*ans)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	i = r - l + 1
	mi = i * (i + 1) // 2
	mx = n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2
	if s < mi or s > mx:
		print(-1)
		continue
	right = n - 1
	left = right - i + 1
	lis = [i for i in range(1, n + 1)]
	flag = 0
	while left > 0:
		sm = sum(lis[left:right + 1])
		if sm == s:
			ans = lis[left:right + 1]
			break
		i = left - 1
		for j in range(left, right + 1):
			if sm - lis[j] + lis[i] == s:
				(lis[i], lis[j]) = (lis[j], lis[i])
				ans = lis[left:right + 1]
				flag = 1
				break
		if flag == 1:
			break
		left -= 1
		right -= 1
	if left == 0:
		ans = lis[left:right + 1]
	dic = {}
	for i in range(1, n + 1):
		dic[i] = 0
	for i in ans:
		dic[i] = 1
	temp_lis = [x for x in range(1, n + 1) if dic[x] == 0]
	final_ans = []
	for i in range(1, n + 1):
		if i < l or i > r:
			final_ans.append(temp_lis.pop(0))
		else:
			final_ans.append(ans.pop(0))
	print(*final_ans)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	values = r - l + 1
	min_sum = values * (values + 1) // 2
	max_sum = min_sum + (n - values) * values
	if s < min_sum or s > max_sum:
		print(-1)
		continue
	subarray = [i for i in range(1, r - l + 2)]
	s = s - min_sum
	max_num = n - values
	for i in range(len(subarray) - 1, -1, -1):
		if s >= max_num:
			subarray[i] += max_num
			s -= max_num
		else:
			subarray[i] += s
			break
	nums = set(subarray)
	other_nums = list(set(range(1, n + 1)) - nums)
	for i in range(l - 1):
		print(other_nums[i], end=' ')
	for item in nums:
		print(item, end=' ')
	for i in range(l - 1, len(other_nums)):
		print(other_nums[i], end=' ')
	print('')


for _ in range(int(input())):
	(n, l, r, s) = [int(x) for x in input().split(' ')]
	k = abs(l - r) + 1
	mn = k * (k + 1) / 2
	mx = mn + (n - k) * k
	if mn <= s and s <= mx:
		a = [i for i in range(k)]
		a.append(n)
		curr = mn
		ptr = k - 1
		while curr != s:
			if a[ptr] + 1 != a[ptr + 1]:
				a[ptr] += 1
				curr += 1
			else:
				ptr -= 1
		a.pop()
		assert len(a) == k
		for i in range(len(a)):
			a[i] += 1
		sa = set(a)
		others = []
		assert len(sa) == len(a)
		for i in range(1, n + 1):
			if not i in sa:
				others.append(i)
		for i in range(l - 1):
			print(others[i], end=' ')
		for x in a:
			print(x, end=' ')
		for i in range(len(others) - (n - r), len(others)):
			print(others[i], end=' ')
		print()
	else:
		print(-1)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def I():
	return int(input())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def AI():
	return map(int, open(0).read().split())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	n = random.randint(1, N)
	a = RLI(n, 0, n - 1)
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]

def gcj(c, x):
	print('Case #{0}:'.format(c + 1), x)

def primeFactor(N):
	(i, n) = (2, N)
	ret = {}
	(d, sq) = (2, 99)
	while i <= sq:
		k = 0
		while n % i == 0:
			(n, k, ret[i]) = (n // i, k + 1, k + 1)
		if k > 0 or i == 97:
			sq = int(n ** (1 / 2) + 0.5)
		if i < 4:
			i = i * 2 - 1
		else:
			(i, d) = (i + d, d ^ 6)
	if n > 1:
		ret[n] = 1
	return ret

def divisor(n):
	div = [1]
	for (i, j) in primeFactor(n).items():
		div = [i ** k * d for d in div for k in range(j + 1)]
	return div

def PrimeNumSet(N):
	M = int(N ** 0.5)
	seachList = [i for i in range(2, N + 1)]
	primes = []
	while seachList:
		if seachList[0] > M:
			break
		primes.append(seachList[0])
		tmp = seachList[0]
		seachList = [i for i in seachList if i % tmp != 0]
	return primes + seachList

def LCM(b, mo=10 ** 9 + 7):
	prs = PrimeNumSet(max(b))
	M = dict(zip(prs, [0] * len(prs)))
	for i in b:
		dc = primeFactor(i)
		for (j, k) in dc.items():
			M[j] = max(M[j], k)
	r = 1
	for (j, k) in M.items():
		if k != 0:
			r *= pow(j, k, mo)
			r %= mo
	return r

def extgcd(x, y):
	if y == 0:
		return (1, 0)
	(r0, r1, s0, s1) = (x, y, 1, 0)
	while r1 != 0:
		(r0, r1, s0, s1) = (r1, r0 % r1, s1, s0 - r0 // r1 * s1)
	return (s0, (r0 - s0 * x) // y, x * s0 + y * (r0 - s0 * x) // y)

def crt(rems, mods):
	n = len(rems)
	if n != len(mods):
		return NotImplemented
	(x, d) = (0, 1)
	for (r, m) in zip(rems, mods):
		(a, b, g) = extgcd(d, m)
		(x, d) = ((m * b * x + d * a * r) // g, d * (m // g))
		x %= d
	for (r, m) in zip(rems, mods):
		if r != x % m:
			return (-1, d)
	return (x, d)

def intsqrt(x):
	if x < 0:
		return NotImplemented
	rt = int(x ** 0.5) - 1
	while (rt + 1) ** 2 <= x:
		rt += 1
	return rt

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % mo

	def cat(self, x):
		if x < 0:
			return 0
		return self.fac[2 * x] * self.inv[x] * self.inv[x + 1] % mo
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	(n, l, r, s) = LI()
	m = r - l + 1
	ans = list(range(1, m + 1))
	x = sum(ans)
	if x > s:
		print(-1)
		continue
	for i in range(m)[::-1]:
		if x < s:
			d = min(s - x, n - m)
			x += d
			ans[i] += d
	if x != s:
		print(-1)
		continue
	rm = set(list(range(1, n + 1))) - set(ans)
	rm = list(rm)
	ans = rm[:l - 1] + ans + rm[l - 1:]
	print(*ans)


t = int(input())
low = lambda k: k * (k + 1) // 2
high = lambda n, k: k * (2 * n - k + 1) // 2
for ti in range(t):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	if s < low(k) or s > high(n, k):
		print(-1)
		continue
	ans = []
	for i in range(n, 0, -1):
		if k > 0 and high(i, k) >= s and (s - i >= low(k - 1)):
			ans.append(i)
			s -= i
			k -= 1
	ans = set(ans)
	setDiff = set(range(1, n + 1)) - ans
	(setDiff, ans) = (list(setDiff), list(ans))
	setDiff[l - 1:l - 1] = ans
	for i in setDiff:
		print(i, end=' ')
	print()


tc = int(input())
for _ in range(tc):
	(n, l, r, s) = list(map(int, input().split()))
	needed = r - l + 1
	minsum = 0
	sum_left = s
	max_left = n
	lis = []
	taken = [False for _ in range(n + 3)]
	for i in range(needed):
		minsum += i + 1
	works = True
	while needed > 0:
		if minsum > sum_left:
			works = False
			break
		if minsum == sum_left:
			minsum -= needed
			sum_left -= needed
			lis.append(needed)
			taken[needed] = True
			needed -= 1
			continue
		minsum -= needed
		if sum_left >= max_left + minsum:
			lis.append(max_left)
		else:
			num = sum_left - minsum
			if 0 < num <= n:
				lis.append(num)
				max_left = num
			else:
				break
		sum_left -= lis[-1]
		needed -= 1
		taken[lis[-1]] = True
		max_left = max_left - 1
	if works and sum(lis) == s and (needed == 0):
		i = 1
		j = 1
		while j <= n:
			if l <= j <= r:
				print(lis[j - l], end=' ')
			else:
				while taken[i]:
					i += 1
				print(i, end=' ')
				i += 1
			j += 1
		print()
	else:
		print(-1)


import sys
import math
from functools import lru_cache
inf = float('inf')

def solve(n, l, r, s):
	k = r - l + 1
	min_sum = k * (k + 1) >> 1
	max_sum = k * (2 * n + 1 - k) >> 1
	if s < min_sum or s > max_sum:
		print(-1)
		return

	def canTake(s, el, k):
		s_hat = s - el
		k -= 1
		return k * (k + 1) >> 1 <= s_hat
	taken = []
	left = []
	for i in range(n, 0, -1):
		if k > 0 and canTake(s, i, k):
			k -= 1
			s -= i
			taken.append(i)
		else:
			left.append(i)
	res = []
	for i in range(1, n + 1):
		if i == l:
			break
		res.append(left.pop())
	res += taken + left
	print(*res, sep=' ')
if 1 == 2:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	input = sys.stdin.readline
T = int(input())
for _ in range(T):
	(n, l, r, s) = list(map(int, input().split()))
	solve(n, l, r, s)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
mod1 = 1000000000 + 7
mod2 = 998244353
for _ in range(I()):
	(n, l, r, s) = M()
	p = []

	def high(n, k):
		return k * (2 * n + 1 - k) // 2

	def low(k):
		return k * (k + 1) // 2

	def solve(k, i, s, p):
		if k == 0 or i == 0:
			return
		if high(i, k) >= s and low(k - 1) <= s - i:
			p.append(i)
			solve(k - 1, i - 1, s - i, p)
		else:
			solve(k, i - 1, s, p)
	solve(r - l + 1, n, s, p)
	if len(p) == r - l + 1 and sum(p) == s:
		d = set(p)
		ans = [0] * n
		i = k = 1
		while i < l:
			if k not in d:
				ans[i - 1] = k
				i += 1
			k += 1
		i = r + 1
		while i < n + 1:
			if k not in d:
				ans[i - 1] = k
				i += 1
			k += 1
		for i in range(l, r + 1):
			ans[i - 1] = p[i - l]
		print(*ans)
	else:
		print(-1)


for _ in range(int(input())):
	(n, s, e, su) = list(map(int, input().split()))
	lis = []
	for i in range(1, n + 1):
		lis.append(i)
	le = e - s + 1
	if sum(lis[len(lis) - le:]) < su or sum(lis[:le]) > su:
		print(-1)
		continue
	new = []
	for i in lis[:le]:
		new.append(i)
	ad = sum(new)
	need = su - ad
	per = need // le
	extra = need - per * le
	m = lis[-1]
	for i in range(le):
		new[i] += per
	if extra > 0:
		for i in range(le - 1, le - extra - 1, -1):
			new[i] += 1
	final = lis.copy()
	for i in new:
		final.remove(i)
	final = final[:s - 1] + new + final[s - 1:]
	string = ''
	for i in final:
		string += str(i) + ' '
	print(string)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	arr = []
	t = []
	visited = set()
	cnt = 0
	warr = []
	for i in range(1, n + 1):
		if i > s:
			t.append(i)
			continue
		arr.append(i)
		if cnt < r - l + 1:
			visited.add(i)
			warr.append(i)
			cnt += 1
	som = sum(arr[0:r - l + 1])
	if sum(arr[-(r - l + 1):]) < s or som > s or len(arr) < r - l + 1:
		print(-1)
		continue
	flag = 0
	for i in range(len(warr)):
		for j in range(len(arr)):
			if som == s:
				flag = 1
				break
			if som - warr[i] + arr[j] > som and som < s and (arr[j] not in visited):
				e1 = warr[i]
				e2 = arr[j]
				visited.remove(warr[i])
				visited.add(arr[j])
				som -= warr[i]
				som += arr[j]
				warr[i] = e2
				continue
			if som > s and som - warr[i] + arr[j] < som and (arr[j] not in visited):
				e1 = warr[i]
				e2 = arr[j]
				visited.remove(warr[i])
				visited.add(arr[j])
				som -= warr[i]
				som += arr[j]
				warr[i] = e2
		if som == s:
			flag = 1
			break
		if flag:
			break
	par = []
	for i in arr:
		if i not in visited:
			par.append(i)
	par = par + t
	ans = [0] * n
	for i in range(n):
		if i < r and i >= l - 1:
			ans[i] = warr.pop()
		else:
			ans[i] = par.pop()
	print(*ans)


t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	l -= 1
	r -= 1
	c = r - l + 1
	if c * (c + 1) // 2 > s or c * (2 * n + 1 - c) // 2 < s:
		print(-1)
		continue
	sec = [i for i in range(1, c + 1)]
	sec.reverse()
	s -= c * (c + 1) // 2
	cnt = 0
	while s > 0:
		s -= 1
		sec[cnt] += 1
		cnt = (cnt + 1) % c
	used = [False] * n
	ans = [0] * n
	ans[l:r + 1] = sec
	for i in sec:
		used[i - 1] = True
	iter = 0
	for i in range(n):
		if ans[i]:
			continue
		while used[iter]:
			iter += 1
		used[iter] = True
		ans[i] = iter + 1
	print(*ans)


def main():
	t = int(input())
	allans = []
	for _ in range(t):
		(n, l, r, s) = readIntArr()
		l -= 1
		r -= 1
		requiredCnt = r - l + 1
		minPossible = sum(range(1, requiredCnt + 1))
		maxPossible = sum(range(n, n - requiredCnt, -1))
		if s < minPossible or s > maxPossible:
			allans.append([-1])
		else:
			v = minPossible
			subArray = list(range(1, requiredCnt + 1))
			topNumberForUse = n
			while v < s:
				for i in range(requiredCnt):
					if topNumberForUse > subArray[i] and v - subArray[i] + topNumberForUse <= s:
						v = v - subArray[i] + topNumberForUse
						subArray[i] = topNumberForUse
						break
				topNumberForUse -= 1
			unusedNumbers = set(range(1, n + 1))
			for x in subArray:
				unusedNumbers.remove(x)
			unusedNumList = list(unusedNumbers)
			unusedI = 0
			left = []
			right = []
			for i in range(n):
				if i < l:
					left.append(unusedNumList[unusedI])
					unusedI += 1
				elif i > r:
					right.append(unusedNumList[unusedI])
					unusedI += 1
			ans = left + subArray + right
			allans.append(ans)
	multiLineArrayOfArraysPrint(allans)
	return
import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')

def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def multiLineArrayPrint(arr):
	print('\n'.join([str(x) for x in arr]))

def multiLineArrayOfArraysPrint(arr):
	print('\n'.join([' '.join([str(x) for x in y]) for y in arr]))

def readIntArr():
	return [int(x) for x in input().split()]

def makeArr(defaultVal, dimensionArr):
	dv = defaultVal
	da = dimensionArr
	if len(da) == 1:
		return [dv for _ in range(da[0])]
	else:
		return [makeArr(dv, da[1:]) for _ in range(da[0])]

def queryInteractive(x, y):
	print('? {} {}'.format(x, y))
	sys.stdout.flush()
	return int(input())

def answerInteractive(ans):
	print('! {}'.format(ans))
	sys.stdout.flush()
inf = float('inf')
MOD = 10 ** 9 + 7
for _abc in range(1):
	main()


def ari(n, start):
	end = start + n - 1
	return (start + end) * n // 2
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	if ari(k, 1) > s:
		print(-1)
		continue
	if ari(k, n - k + 1) < s:
		print(-1)
		continue
	segment = []
	for i in range(n - k + 2):
		if ari(k, i) >= s:
			segment = list(range(i, i + k))
			diff = ari(k, i) - s
			for seg_i in range(diff):
				segment[seg_i] -= 1
			break
	used = [0] * (n + 1)
	for v in segment:
		used[v] = 1
	other = []
	for i in range(1, n + 1):
		if not used[i]:
			other.append(i)
	ans = other[:l - 1] + segment + other[l - 1:]
	print(*ans)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	l -= 1
	k = r - l
	if sum(range(1, 1 + k)) <= s <= sum(range(n + 1 - k, n + 1)):
		togo = s - sum(range(1, 1 + k))
		A = list(range(1 + togo // k, 1 + togo // k + k))
		togo %= k
		for i in range(k - togo, k):
			A[i] += 1
		trash = list(set(range(1, n + 1)) - set(A))
		print(*trash[:l] + A + trash[l:])
	else:
		print(-1)


def solve(n: int, l: int, r: int, s: int) -> str:
	max_sum = 0
	for i in range(n, n - (r - l + 1), -1):
		max_sum += i
	if s > max_sum:
		return '-1'
	arr = [i for i in range(1, r - l + 2)]
	total = sum(arr)
	if s < total:
		return '-1'
	nums = [i for i in range(1, n + 1)]
	max_index = n - 1
	curr_index = r - l
	while total < s:
		new_val = min(arr[curr_index] + s - total, nums[max_index])
		change = new_val - arr[curr_index]
		total += change
		arr[curr_index] = new_val
		curr_index -= 1
		max_index -= 1
	good_nums = set(arr)
	garbage_nums = []
	for i in range(1, n + 1):
		if i not in good_nums:
			garbage_nums.append(i)
	good_index = 0
	garbage_index = 0
	ans = []
	for i in range(n):
		if i >= l - 1 and i < r:
			ans.append(arr[good_index])
			good_index += 1
		else:
			ans.append(garbage_nums[garbage_index])
			garbage_index += 1
	ans_str = ''
	for x in ans:
		ans_str += str(x) + ' '
	return ans_str
test_cases = int(input())
for _ in range(test_cases):
	(n, l, r, s) = list(map(int, input().split()))
	print(solve(n, l, r, s))


from collections import deque, defaultdict
from math import sqrt, ceil, factorial, floor, inf, gcd
import bisect
import sys
import copy

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, l, r, s) = get_ints()
	dist = r - l + 1
	st = list(range(1, dist + 1))
	end = list(range(n - dist + 1, n + 1))
	max_pos = sum(end)
	min_pos = sum(st)
	if s >= min_pos and s <= max_pos:
		diff = s - min_pos
		for i in range(dist - 1, -1, -1):
			if diff >= end[i] - st[i]:
				diff -= end[i] - st[i]
				st[i] = end[i]
			elif diff > 0:
				st[i] = st[i] + diff
				diff = 0
			if diff == 0:
				break
		remained = list(set(range(1, n + 1)) - set(st))
		for i in range(l - 1):
			print(remained.pop(), end=' ')
		print(*st, end=' ')
		print(*remained)
	else:
		print(-1)


def rec(s, l, arr):
	arr_ = arr[:l]
	if sum(arr_) == s:
		return arr_
	while arr_[-1] < arr[-1]:
		for i in range(l - 1, -1, -1):
			arr_[i] += 1
			if sum(arr_) == s:
				return arr_
	return None

def solve():
	(n, l, r, s) = map(int, input().split(' '))
	l -= 1
	r -= 1
	re = rec(s, r - l + 1, [i + 1 for i in range(n)])
	if re == None:
		print(-1)
		return
	st = list(set([i + 1 for i in range(n)]) - set(re))
	res = [None] * n
	i = 0
	for j in range(l):
		res[j] = st[i]
		i += 1
	for j in range(r + 1, n):
		res[j] = st[i]
		i += 1
	i = 0
	for j in range(l, r + 1):
		res[j] = re[i]
		i += 1
	print(*res)
for t in range(int(input())):
	solve()


import os
import sys
from io import BytesIO, IOBase

def main():
	import bisect
	import math
	import itertools
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	inf = 1e+17
	mod = 10 ** 9 + 7

	def solve(n, l, r, s):
		p = []
		for i in range(1, n + 1):
			p.append(i)
		length = r - l + 1
		pre = [0]
		for i in range(n):
			pre.append(pre[-1] + p[i])
		can = []
		for i in range(n - length + 1):
			can.append(pre[i + length] - pre[i])
		if s < can[0] or s > can[-1]:
			return -1
		not_taken = set(list(p))
		taken = []
		for i in range(n - length + 1):
			if can[i] == s:
				for j in range(i, i + length):
					taken.append(p[j])
					not_taken.remove(p[j])
				break
			elif can[i] > s:
				diff = can[i] - s
				if diff <= i:
					taken.append(p[i - diff])
					not_taken.remove(p[i - diff])
					for j in range(i + 1, i + length):
						taken.append(p[j])
						not_taken.remove(p[j])
				else:
					taken.append(p[0])
					not_taken.remove(p[0])
					for j in range(i, i + length):
						if p[0] + diff != p[j]:
							taken.append(p[j])
							not_taken.remove(p[j])
				break
			else:
				continue
		answer = []
		not_taken_list = list(not_taken)
		for j in range(l - 1):
			answer.append(not_taken_list[j])
		answer += taken
		for j in range(l - 1, n - length):
			answer.append(not_taken_list[j])
		return ' '.join(list(map(str, answer)))
	t = int(input())
	ans = []
	for _ in range(t):
		(n, l, r, s) = map(int, input().split())
		ans.append(solve(n, l, r, s))
	for test in ans:
		print(test)
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	p = n - k
	if s < k * (k + 1) / 2 or s > n * (n + 1) / 2 - p * (p + 1) / 2:
		print(-1)
	else:
		perm = [i + 1 for i in range(n)]
		ans = [i + 1 for i in range(r - l + 1)]
		vist = [False for i in range(n + 1)]
		ss = sum(ans)
		last = len(ans) - 1
		high = n - 1
		while last >= 0:
			curr = last + 1
			if ss == s:
				break
			else:
				while curr <= high:
					if ss == s:
						break
					ss += 1
					ans[last] += 1
					curr += 1
				high -= 1
				last -= 1
		for i in ans:
			vist[i] = True
		rem = []
		total = []
		for j in perm:
			if not vist[j]:
				rem.append(j)
		ind = 0
		for i in range(1, n + 1):
			if i != l:
				if ind >= len(rem):
					continue
				total.append(rem[ind])
				ind += 1
			else:
				for j in ans:
					total.append(j)
		print(*total)


def solve(N, L, R, S):
	n = N
	(max_val, min_val) = (0, (1 + R - L + 1) * (R - L + 1) // 2)
	for _ in range(R - L + 1):
		max_val += n
		n -= 1
	if not min_val <= S <= max_val:
		return -1
	diff = max_val - S
	can = []
	for i in range(R - L + 1):
		can += [N - i]
	can.reverse()
	idx = 0
	while diff:
		curr = min(diff, can[idx] - (idx + 1))
		can[idx] -= curr
		diff -= curr
		idx += 1
	ans = []
	idx = 0
	all_can = set([i + 1 for i in range(N)])
	for c in can:
		all_can.remove(c)
	for i in range(1, N + 1, 1):
		if i < L or i > R:
			ans += [str(all_can.pop())]
		else:
			ans += [str(can[idx])]
			idx += 1
	return ' '.join(ans)
T = int(input())
for _ in range(T):
	(N, L, R, S) = map(int, input().split())
	print(solve(N, L, R, S))


import sys
from io import BytesIO, IOBase
import heapq as h
import bisect
import math as mt
from types import GeneratorType
BUFSIZE = 8192

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import sys
from math import ceil, log2
INT_MAX = sys.maxsize
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def minVal(x, y):
	return x if x < y else y

def getMid(s, e):
	return s + (e - s) // 2

def RMQUtil(st, ss, se, qs, qe, index):
	if qs <= ss and qe >= se:
		return st[index]
	if se < qs or ss > qe:
		return INT_MAX
	mid = getMid(ss, se)
	return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2))

def RMQ(st, n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input')
		return -1
	return RMQUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2))
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * int(2 ** x) - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st
MOD = 10 ** 9 + 7
mod = 10 ** 9 + 7
p = 10 ** 9 + 7

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def z_array(s1):
	n = len(s1)
	z = [0] * n
	(l, r, k) = (0, 0, 0)
	for i in range(1, n):
		if i > r:
			(l, r) = (i, i)
			while r < n and s1[r - l] == s1[r]:
				r += 1
			z[i] = r - l
			r -= 1
		else:
			k = i - l
			if z[k] < r - i + 1:
				z[i] = z[k]
			else:
				l = i
				while r < n and s1[r - l] == s1[r]:
					r += 1
				z[i] = r - l
				r -= 1
	return z

def fs(x):
	if x < 2:
		return 0
	return x * (x - 1) // 2
t = int(input())

def solve():
	x = r - l + 1
	s1 = x * (x + 1) // 2
	fs = n * (n + 1) // 2
	x1 = n - x
	s2 = fs - x1 * (x1 + 1) // 2
	ans = []
	pref = [0] * (n + 1)
	suf = [0] * (n + 1)
	suma = 0
	d = {}
	if s >= s1 and s <= s2:
		for i in range(1, n + 1):
			snew = s - i
			ans.append(i)
			xnew = x - len(ans)
			suma += ans[-1]
			(suma1, suma2) = (0, 0)
			for j in range(i + 1, min(i + xnew, n + 1)):
				suma1 += j
			for j in range(n, max(n - xnew, i), -1):
				suma2 += j
			if suma1 + suma <= s and suma2 + suma >= s:
				d[i] = 1
				pass
			else:
				suma -= ans[-1]
				ans.pop()
		ans1 = []
		for i in range(1, l):
			for j in range(1, n + 1):
				if d.get(j, -1) == -1:
					d[j] = 1
					ans1.append(j)
					break
		for i in ans:
			ans1.append(i)
		for i in range(r, n):
			for j in range(1, n + 1):
				if d.get(j, -1) == -1:
					d[j] = 1
					ans1.append(j)
					break
		print(*ans1)
	else:
		print(-1)
		return
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	solve()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	y = sum(range(n - x + 1, n + 1))
	z = sum(range(1, x + 1))
	if s > y or s < z:
		print(-1)
	else:
		test = n - x + 1
		s1 = []
		for i in range(1, n + 1):
			if y - test + i >= s:
				s1.append(i)
				y += i - test
				test += 1
		s2 = list(set(range(1, n + 1)) - set(s1))
		ans = s2[:l - 1] + s1 + s2[l - 1:]
		print(*ans)


T = int(input())
for _ in range(T):
	(n, l, r, k) = map(int, input().split())
	_len = r - l + 1
	lb = (_len + 1) * _len // 2
	ub = (n + n - _len + 1) * _len // 2
	ans = [0] * n
	used = []
	if lb <= k <= ub:
		dis = k - lb
		step = dis // _len
		rem = dis % _len
		for i in range(_len):
			start = 1 + step
			if i > _len - rem - 1:
				used.append(i + start + 1)
			else:
				used.append(i + start)
		cnt = 0
		for i in range(1, n + 1):
			if l <= i <= r:
				ans[i - 1] = used[cnt]
				cnt += 1
				continue
			for num in range(1, n + 1):
				if num not in used:
					used.append(num)
					ans[i - 1] = num
					break
		print(*ans)
	else:
		print(-1)


for i in range(int(input())):
	(n, l, r, s) = [int(n) for n in input().split()]
	length = r - l + 1
	max_sum = length * (2 * n + 1 - length) // 2
	min_sum = length * (length + 1) // 2
	if s > max_sum or s < min_sum:
		print('-1')
	else:
		(left_part, right_part) = ([], [])
		for j in range(n, 0, -1):
			if length > 0 and length * (2 * j + 1 - length) // 2 >= s and (s - j >= (length - 1) * length // 2):
				right_part.append(j)
				length = length - 1
				s = s - j
			else:
				left_part.append(j)
		if s > 0:
			print('-1')
		else:
			for j in right_part:
				left_part.insert(l - 1, j)
				l += 1
		print(*left_part)


t = int(input())

def high(i, k):
	return k * (2 * i + 1 - k) / 2

def low(k):
	return k * (k + 1) / 2

def fun(n, width, s):
	rset = []
	if width == 1:
		rset.append(s)
		return rset
	if s == width * (width + 1) // 2:
		return list(range(1, width + 1))
	if high(n, width) >= s and s - n >= low(width - 1):
		rset.append(n)
		rset += fun(n - 1, width - 1, s - n)
	else:
		rset += fun(n - 1, width, s)
	return rset
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	ran = list(range(1, n + 1))
	width = r - l + 1
	if s < sum(ran[:width]) or s > sum(ran[-width:]):
		print(-1, end='')
	else:
		lr = fun(n, width, s)
		non_lr = [ele for ele in ran if ele not in lr]
		res = non_lr[:l - 1] + lr + non_lr[l - 1:]
		for ele in res:
			print(ele, end=' ')
	print('')


def helper(n, l, r, s):
	count = r - l + 1
	low = (1 + count) * count // 2
	high = (n + n - count + 1) * count // 2
	if s < low or s > high:
		return []
	res = [0] * n
	used = set(list())
	tl = 1
	tr = n
	while l < r:
		if s <= (tl + tr) * count / 2:
			res[l - 1] = tl
			tl += 1
			used.add(res[l - 1])
			s -= res[l - 1]
			l += 1
			count -= 1
		else:
			res[r - 1] = tr
			tr -= 1
			used.add(res[r - 1])
			s -= res[r - 1]
			r -= 1
			count -= 1
	res[l - 1] = s
	used.add(res[l - 1])
	curr = 1
	for i in range(n):
		if res[i] != 0:
			continue
		while curr in used:
			curr += 1
		res[i] = curr
		used.add(curr)
	return res
t = int(input())
for i in range(t):
	(n, l, r, s) = map(int, input().split(' '))
	res = helper(n, l, r, s)
	if not res:
		print('-1')
	else:
		print(' '.join(list(map(str, res))))


import sys, math
from itertools import permutations, combinations
from collections import defaultdict, deque
input = sys.stdin.readline
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	diff = r - l + 1
	if diff * (diff + 1) // 2 > s:
		print(-1)
		continue
	maxi = n
	cur = 0
	for i in range(diff):
		cur += maxi
		maxi -= 1
	if s > cur:
		print(-1)
		continue
	p = [0 for _ in range(n)]
	l -= 1
	r -= 1
	c = 1
	for i in range(l, r + 1):
		p[i] = c
		s -= c
		c += 1
	right = r
	maxi = n
	while s > 0 and right >= l:
		cur = p[right]
		diff = maxi - cur
		if diff > s:
			p[right] += s
			s = 0
		else:
			s -= diff
			p[right] = maxi
		maxi -= 1
		right -= 1
	seen = set()
	for i in p:
		if i != 0:
			seen.add(i)
	nl = []
	for i in range(n):
		if i + 1 not in seen:
			nl.append(i + 1)
	for i in range(n):
		if p[i] == 0:
			p[i] = nl.pop()
	print(*p)


def solve(n, l, r, s):
	a = r - l + 1
	u = (n - a + 1 + n) * a // 2
	w = (a + 1) * a // 2
	if not w <= s <= u:
		print(-1)
		return
	m = list(reversed(range(1, a + 1)))
	s -= w
	for i in range(a):
		y = n - i
		if s > y - m[i]:
			s -= y - m[i]
			m[i] = y
		else:
			m[i] += s
			break
	t = set(m)
	b = []
	c = 1
	for i in range(l - 1):
		while c in t:
			c += 1
		b += [c]
		t.add(c)
	f = []
	for i in range(n - r):
		while c in t:
			c += 1
		f += [c]
		t.add(c)
	print(*b, *m, *f)
t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	solve(n, l, r, s)


from collections import deque
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	nums = r - l + 1
	minSum = 0
	maxSum = 0
	for i in range(nums):
		minSum += i + 1
		maxSum += n - i
	if s < minSum or s > maxSum:
		print(-1)
	else:
		ans = deque([i + 1 for i in range(n - l + 1, n)] + [i + 1 for i in range(n - l + 1)])
		turns = l - 1
		begin = 1
		while minSum < s:
			begin += 1
			minSum += nums
			ans.append(ans.popleft())
			turns += 1
		if minSum == s:
			print(*ans)
		else:
			diff = minSum - s
			(ans[(l - 2) % n], ans[(l + diff - 2) % n]) = (ans[(l + diff - 2) % n], ans[(l - 2) % n])
			print(*ans)


def some_random_function():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function5():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, l, r, s) = map(int, input().split())
		z = r - l + 1
		if s < z * (z + 1) // 2 or s > z * n - z * (z - 1) // 2:
			print(-1)
			continue
		val = list(range(1, z + 1))
		s -= z * (z + 1) // 2
		co = 0
		for j in range(len(val) - 1, -1, -1):
			xx = min(n - co - val[j], s)
			val[j] += xx
			co += 1
			s -= xx
		ans = [0] * n
		for i in range(l - 1, r):
			ans[i] = val[i - l]
		se = set(val)
		ind = 0
		for i in range(1, n + 1):
			if ind == l - 1:
				ind = r
			if i not in se:
				ans[ind] = i
				ind += 1
		print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def some_random_function1():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function2():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function3():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function4():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function6():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function7():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)

def some_random_function8():
	x = 10
	x *= 100
	i_dont_know = x
	why_am_i_writing_this = x * x
	print(i_dont_know)
	print(why_am_i_writing_this)
main()


import sys
input = sys.stdin.readline
for CASES in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	l -= 1
	r -= 1
	le = r - l + 1
	now = (1 + le) * le // 2
	if now > s:
		print(-1)
		continue
	A = [0] * n
	for i in range(l, r + 1):
		A[i] = i - l + 1
	for i in range(r, l - 1, -1):
		delta = n + i - r - A[i]
		if now + delta <= s:
			A[i] += delta
			now += delta
		else:
			A[i] += s - now
			now += s - now
			break
	if now != s:
		print(-1)
		continue
	B = set(A)
	tmp = 1
	for i in range(len(A)):
		if A[i] == 0:
			while tmp in B:
				tmp += 1
			B.add(tmp)
			A[i] = tmp
	print(*A)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = [0] * n
	p = r - l + 1
	t = n * (n + 1) // 2
	q = (n - p) * (n - p + 1) // 2
	if p * (p + 1) // 2 > s or t - q < s:
		print(-1)
		continue
	a = 1
	p = 0
	t = set()
	for i in range(l - 1, r):
		k[i] = a
		p += a
		t.add(a)
		a += 1
	while s - p:
		for i in range(l - 1, r):
			if k[i] + s - p <= n and k[i] + s - p not in t:
				t.add(k[i] + s - p)
				t.discard(k[i])
				k[i] = k[i] + s - p
				p = s
				break
			elif k[i] + s - p > n:
				a = n
				while a in t:
					a -= 1
				t.remove(k[i])
				t.add(a)
				p -= k[i]
				k[i] = a
				p += k[i]
	q = []
	for i in range(1, n + 1):
		if i not in t:
			q.append(i)
	for i in range(n):
		if k[i] == 0:
			k[i] = q.pop()
	print(*k)


for t in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	l = l - 1
	k = r - l
	if sum(range(1, 1 + k)) <= s <= sum(range(n + 1 - k, n + 1)):
		g = s - sum(range(1, 1 + k))
		A = list(range(1 + g // k, 1 + g // k + k))
		g %= k
		for i in range(k - g, k):
			A[i] += 1
		trash = list(set(range(1, n + 1)) - set(A))
		print(*trash[:l] + A + trash[l:])
	else:
		print(-1)


def solve():
	(n, l, r, s) = [int(i) for i in input().split()]
	k = r - l + 1
	l1 = [0] * n
	l2 = [i for i in range(1, n + 1)]
	l3 = []
	low = k * (k + 1) // 2
	high = k * (2 * n + 1 - k) // 2
	if s < low or high < s:
		print(-1)
		return
	c = l - 1
	for i in range(n, 0, -1):
		if k > 0 and s <= k * (2 * i + 1 - k) // 2 and (s - i >= k * (k - 1) // 2):
			l1[c] = i
			c += 1
			s -= i
			k -= 1
			l2[i - 1] = -1
	for i in range(n):
		if l2[i] != -1:
			l3.append(l2[i])
	c1 = 0
	for i in range(l - 1):
		l1[i] = l3[c1]
		c1 += 1
	for i in range(r, n):
		l1[i] = l3[c1]
		c1 += 1
	print(*l1)
	return

def main():
	T = int(input())
	for t in range(T):
		solve()
	return
main()


import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	r = int(l[2])
	s = int(l[3])
	l = int(l[1])
	ok = 0
	for i in range(n, n - (r - l + 1), -1):
		ok += i
	if s > ok:
		print(-1)
		continue
	if s < r - l + 1:
		print(-1)
		continue
	l -= 1
	r -= 1
	p = [0 for i in range(n)]
	for i in range(l, r + 1):
		p[i] = i - l + 1
	z = sum(p[l:r + 1])
	if s < z:
		print(-1)
		continue
	s -= z
	currmax = n
	for i in range(r, l - 1, -1):
		inc = currmax - p[i]
		if inc < s:
			p[i] += inc
			s -= inc
			currmax -= 1
		else:
			p[i] += s
			break
	hashi = dict()
	for i in range(1, n + 1):
		hashi[i] = 1
	for i in range(l, r + 1):
		del hashi[p[i]]
	op = []
	for i in hashi:
		op.append(i)
	curr = 0
	for i in range(n):
		if p[i] == 0:
			p[i] = op[curr]
			curr += 1
	for i in range(n):
		print(p[i], end=' ')
	print()


for i in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	d = r - l + 1
	mi = d * (d + 1) // 2
	ma = n * (n + 1) // 2 - (n - d) * (n - d + 1) // 2
	if s < mi or s > ma:
		print(-1)
	else:
		li = []
		for jj in range(d):
			li.append(jj + 1)
			s -= jj + 1
		zz = n
		for jj in range(d - 1, -1, -1):
			if s == 0:
				break
			if s < zz - li[jj]:
				li[jj] += s
				s = 0
			else:
				s -= zz - li[jj]
				li[jj] = zz
			zz -= 1
		rr = []
		for jj in range(1, n + 1):
			if jj not in li:
				rr.append(jj)
		(p, q) = (0, 0)
		for jj in range(1, n + 1):
			if jj >= l and jj <= r:
				print(li[p], end=' ')
				p += 1
			else:
				print(rr[q], end=' ')
				q += 1
		print()


t = int(input())
while t:
	t -= 1
	(n, l, r, s) = map(int, input().split())
	interval = r - l + 1
	if s < interval * (interval + 1) // 2 or s > (2 * n - interval + 1) * (interval // 2) + interval % 2 * ((2 * n - interval + 1) // 2):
		print(-1)
		continue
	s -= interval * (interval + 1) // 2
	(forward, remained) = (s // interval, s % interval)
	res = [0] * n
	start = 1 + forward
	end = start + interval - 1 + remained
	if end < n + 1:
		for i in range(l, r):
			res[i - 1] = start + i - l
		res[r - 1] = end
		exist = set(res[l - 1:r])
		nonexist = list(set([i for i in range(1, n + 1)]) - exist)
		res[:l - 1] = nonexist[:l - 1]
		res[r:] = nonexist[l - 1:]
	else:
		start += 1
		end = start + interval - 1
		total = 0
		for i in range(start, start + interval):
			total += i
		start -= total - s - interval * (interval + 1) // 2
		if start > 0:
			res[l - 1] = start
			temp = end
			for i in range(r - 1, l - 1, -1):
				res[i] = temp
				temp -= 1
			exist = set(res[l - 1:r])
			nonexist = list(set([i for i in range(1, n + 1)]) - exist)
			res[:l - 1] = nonexist[:l - 1]
			res[r:] = nonexist[l - 1:]
		else:
			start += total - s - interval * (interval + 1) // 2
			end = start + interval - 1
			m = [i for i in range(start, end + 1)]
			total = sum(m)
			ix = 0
			while total != s + interval * (interval + 1) // 2:
				m[ix % interval] -= 1
				ix += 1
				total -= 1
			res[l - 1:r] = m
			exist = set(res[l - 1:r])
			nonexist = list(set([i for i in range(1, n + 1)]) - exist)
			res[:l - 1] = nonexist[:l - 1]
			res[r:] = nonexist[l - 1:]
	print(*res)


t = int(input())
for i in range(t):
	(n, l, r, s) = map(int, input().split())
	ans = 0
	s1 = 0
	k = 1
	a = []
	for j in range(r - l + 1):
		s1 = s1 + k
		a.append(k)
		k = k + 1
	s2 = 0
	k = n
	for j in range(r - l + 1):
		s2 = s2 + k
		k = k - 1
	if s <= s2 and s >= s1:
		k = r - l + 1
		o = n
		for j in range(r - l + 1):
			if s1 == s:
				break
			elif s - s1 <= o - k:
				a[k - 1] = a[k - 1] + (s - s1)
				s1 = s1 + (s - s1)
			else:
				a[k - 1] = o
				s1 = s1 + (o - k)
			k = k - 1
			o = o - 1
		j = 1
		pn = 1
		while j < l:
			if pn not in a:
				print(pn, end=' ')
				j = j + 1
			pn = pn + 1
		for j in a:
			print(j, end=' ')
		j = r + 1
		while j <= n:
			if pn not in a:
				print(pn, end=' ')
				j = j + 1
			pn = pn + 1
		print()
	else:
		print('-1')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter, defaultdict
import math
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	arr = [i for i in range(1, n + 1)]
	ls = [0] * n
	vis = [0] * 1000
	var = 1
	for i in range(l - 1, r):
		ls[i] = var
		var += 1
	diff = s - (r - l + 1) * (r - l + 2) // 2
	if diff < 0:
		print(-1)
	else:
		maxx = n
		for i in range(r - 1, max(l - 2, -1), -1):
			if diff == 0:
				vis[ls[i]] = 1
				continue
			v1 = maxx - ls[i]
			mi = min(v1, diff)
			ls[i] += mi
			vis[ls[i]] = 1
			diff -= mi
			maxx -= 1
		if diff > 0:
			print(-1)
		else:
			var = 1
			for i in range(n):
				if ls[i] != 0:
					continue
				while vis[var] == 1:
					var += 1
				ls[i] = var
				var += 1
			if var > n + 1:
				print(-1)
			else:
				print(*ls)


import random
import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
S = lambda : list(map(str, input()))
(t,) = I()
for t1 in range(t):
	(n, l, r, s) = I()
	final = []
	k = 0
	dp = [False for i in range(n + 1)]
	min1 = 0
	for i in range(l, r + 1):
		final.append(k + 1)
		k += 1
		dp[k] = True
		min1 += k
	max1 = r - l + 1
	if min1 > s:
		print(-1)
	else:
		remain = s - min1
		k1 = len(final) - 1
		for i in range(len(dp) - 1, 0, -1):
			if remain == 0:
				break
			if dp[i] == False and k1 >= 0:
				if remain + final[k1] - i >= 0:
					dp[final[k1]] = False
					remain += final[k1]
					final[k1] = i
					dp[final[k1]] = True
					remain -= final[k1]
					k1 -= 1
			else:
				break
		if remain != 0:
			print(-1)
		else:
			dp1 = []
			for i in range(1, len(dp)):
				if dp[i] == False:
					dp1.append(i)
			dp = dp1.copy()
			ans = []
			i = 1
			w = 0
			countxx = 0
			while i < n + 1:
				if i == l:
					ans += final
					i += len(final)
				elif w < len(dp):
					ans.append(dp[w])
					w += 1
					i += 1
				else:
					countxx = 1
					break
			if countxx == 1:
				print(-1)
			else:
				print(*ans)


for _ in range(int(input())):
	(n, l, r, s) = list(map(int, input().split()))
	l -= 1
	r -= 1
	k = r - l + 1
	a = [0 for _ in range(n)]
	j = 1
	for i in range(l, r + 1):
		a[i] = j
		j += 1
	s1 = k * (k + 1) // 2
	s2 = k * (2 * n - k + 1) // 2
	if s < s1 or s > s2:
		print(-1)
	else:
		q = (s - s1) // k
		x = (s - s1) % k
		b = [1 for _ in range(n)]
		for i in range(l, r + 1):
			a[i] += q
		i = r
		while x:
			a[i] += 1
			x -= 1
			i -= 1
		for i in range(l, r + 1):
			b[a[i] - 1] = 0
		j = 0
		for i in range(n):
			if a[i] == 0:
				while b[j] == 0:
					j += 1
				a[i] = j + 1
				j += 1
		print(*a)


import math

def sm(n):
	return n * (n + 1) // 2

def back(n, ln, s):
	if sm(ln) > s:
		return -1
	if sm(n) - sm(n - ln) < s:
		return -1
	l = []
	for i in range(ln):
		l.append(i + 1)
	diff = s - sm(ln)
	if diff == 0:
		return l
	y = n
	x = ln - 1
	while diff != 0:
		if diff >= y - l[x]:
			diff -= y - l[x]
			l[x] = y
			y -= 1
			x -= 1
		else:
			y -= 1
	return l
t = int(input())
for k in range(t):
	(n, l, r, s) = map(int, input().split())
	ln = r - l + 1
	ans = back(n, ln, s)
	if ans == -1:
		print(ans)
	else:
		s = set()
		for i in ans:
			s.add(i)
		j = 1
		while j in s:
			j += 1
		prefix = []
		for i in range(l - 1):
			prefix.append(j)
			j += 1
			while j in s:
				j += 1
		suffix = []
		for i in range(n - r):
			suffix.append(j)
			j += 1
			while j in s:
				j += 1
		print(*prefix + ans + suffix)


I = lambda : [*map(int, input().split())]

def out(x):
	print(str(x))

def solve():
	(n, l, r, s) = I()
	c = [i for i in range(1, r - l + 2)]
	sm = sum(c)
	if sm > s:
		out(-1)
		return
	ci = len(c) - 1
	free = set((i for i in range(r - l + 2, n + 1)))
	used = set(c)
	while ci >= 0 and sm < s:
		if c[ci] + 1 not in free:
			ci -= 1
			continue
		used.remove(c[ci])
		free.add(c[ci])
		used.add(c[ci] + 1)
		free.remove(c[ci] + 1)
		c[ci] += 1
		sm += 1
	if sm != s:
		out(-1)
		return
	result = [f'{i}' for i in free]
	result = result[:l - 1] + list(map(str, c)) + result[l - 1:]
	out(' '.join(result))
(t,) = I()
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	(summ1, summ2) = (0, 0)
	for i in range(1, r - l + 2):
		summ1 += i
	for i in range(n - r + l, n + 1):
		summ2 += i
	if summ1 <= s <= summ2:
		a = []
		for i in range((s - summ1) // (r - l + 1) + 1, (s - summ1) // (r - l + 1) + 1 + (r - l + 1)):
			a.append(i)
		for i in range(r - l + 1 - (s - summ1) % (r - l + 1), r - l + 1):
			a[i] += 1
		a1 = set()
		for i in range(1, n + 1):
			a1.add(i)
		a1 -= set(a)
		a1 = list(a1)
		print(*a1[:l - 1] + a + a1[l - 1:])
	else:
		print(-1)


def check(l, r, s, num):
	tmp1 = (2 * l + num - 1) * num // 2
	tmp2 = (2 * r - num + 1) * num // 2
	return s >= tmp1 and s <= tmp2
cas = int(input())
while cas:
	cas -= 1
	(n, l, r, s) = map(int, input().split())
	a = [0 for i in range(n + 1)]
	vis = [0 for i in range(n + 1)]
	cnt = l
	for i in range(1, n + 1):
		if cnt == r and s <= n and (s >= 1):
			a[cnt] = s
			vis[s] = 1
			s = 0
			break
		if check(i + 1, n, s - i, r - cnt):
			a[cnt] = i
			vis[i] = 1
			cnt += 1
			s -= i
	if s:
		print('-1')
	else:
		pos = 1
		for i in range(1, l):
			while vis[pos]:
				pos += 1
			a[i] = pos
			pos += 1
		for i in range(r + 1, n + 1):
			while vis[pos]:
				pos += 1
			a[i] = pos
			pos += 1
		for i in range(1, n + 1):
			if i == n:
				print(a[i])
			else:
				print(a[i], end=' ')


def main():
	T = int(input())
	while T:
		(n, l, r, s) = map(int, input().split())
		if s < (r - l + 1) * (r - l + 2) // 2 or s > (r - l + 1) * (r - l + 2) // 2 + (r - l + 1) * (n - (r - l + 1)):
			print(-1)
		else:
			LR = [i for i in range(1, r - l + 2)]
			s -= (r - l + 1) * (r - l + 2) // 2
			i = r - l
			while s:
				LR[i] += min(s, n - (r - l + 1))
				s -= min(s, n - (r - l + 1))
				i -= 1
			already_used = set(LR)
			result = [0] * (l - 1) + LR + [0] * (n - r)
			i = 1
			for j in range(n):
				if result[j] == 0:
					while i in already_used:
						i += 1
					result[j] = i
					i += 1
			for i in result:
				print(i, end=' ')
			print()
		T -= 1
main()


def f(a, b):
	ans = 0
	for i in range(a, b + 1):
		ans += i
	return ans
for tc in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	leng = r - l + 1
	if f(1, leng) > s or f(n - leng + 1, n) < s:
		print(-1)
		continue
	lr = [i for i in range(n - leng + 1, n + 1)]
	summ = sum(lr)
	t = 0
	while summ > s:
		summ -= lr[t]
		summ += t + 1
		lr[t] = t + 1
		t += 1
	t -= 1
	while summ < s:
		lr[t] += 1
		summ += 1
	book = [0 for i in range(n + 5)]
	for i in lr:
		book[i] = 1
	t = 1
	for i in range(l - 1):
		while book[t] == 1:
			t += 1
		print(t, end=' ')
		book[t] = 1
	print(' '.join([str(i) for i in lr]), end=' ')
	for i in range(n - r):
		while book[t] == 1:
			t += 1
		print(t, end=' ')
		book[t] = 1
	print()


def somme(n, k, s):
	if s < k * (k + 1) // 2:
		return -1
	if s > n * (n + 1) // 2 - (n - k) * (n - k + 1) // 2:
		return -1
	l = []
	rs = s
	rk = k
	for i in range(k):
		rk -= 1
		x = min(n - i, rs - rk * (rk + 1) // 2)
		rs -= x
		l.append(x)
	return l
for kT in range(int(input())):
	[n, l, r, s] = list(map(int, input().split()))
	f = somme(n, r - l + 1, s)
	if f == -1:
		print(-1)
	else:
		rep = []
		j = 1
		for i in range(l - 1):
			while j in f:
				j += 1
			rep.append(str(j))
			j += 1
		rep += map(str, f)
		for i in range(r + 1, n + 1):
			while j in f:
				j += 1
			rep.append(str(j))
			j += 1
		print(' '.join(rep))


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split(' '))
	t = r - l + 1
	l = l - 1
	r = r - 1
	lo = t * (t + 1) // 2
	hi = t * (2 * n - t + 1) // 2
	if s > hi or s < lo:
		print(-1)
	else:
		res = [i for i in range(1, t + 1)]
		res.reverse()
		curr = lo
		p = n
		for i in range(t):
			if curr + p - res[i] > s:
				x = s - curr
				res[i] = res[i] + x
				break
			elif curr + p - res[i] == s:
				res[i] = p
				break
			else:
				curr = curr + p - res[i]
				res[i] = p
			p = p - 1
		n1 = l
		n2 = n - 1 - r
		ans = [0] * n
		ans[l:r + 1] = res
		arr2 = []
		for item in range(1, n + 1):
			if item not in res:
				arr2.append(item)
		for i in range(n):
			if ans[i] == 0:
				ans[i] = arr2.pop()
		for item in ans:
			print(item, end=' ')
		print('')


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = 0
	while left <= right:
		mid = (right + left) // 2
		if arr[mid][0] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	reserve = 0
	a = [0] * n
	st = set()
	c = 0
	for i in range(l, r + 1):
		reserve += i - l + 1
		c += 1
	k = n
	ss = 0
	ch = 1
	for i in range(l - 1, r):
		reserve -= c
		c -= 1
		while ss + k + reserve > s and k > 0:
			k -= 1
		if k == 0:
			ch = 0
			break
		a[i] = k
		ss += k
		st.add(k)
		k -= 1
	if ss != s:
		ch = 0
	if ch == 0:
		print(-1)
		continue
	k = 1
	for i in range(n):
		if a[i]:
			continue
		while k in st:
			k += 1
		st.add(k)
		a[i] = k
	print(*a)


for test in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	lst = [i for i in range(n, 0, -1)]
	x = r - l + 1
	store = set()
	for i in range(n):
		if x * (x - 1) // 2 <= s - lst[i]:
			store.add(lst[i])
			x -= 1
			s -= lst[i]
	if len(store) == r - l + 1:
		arr = [i for i in range(1, n + 1) if i not in store]
		arr[l - 1:l - 1] = store
		print(*arr)
	else:
		print(-1)


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	(n, l, r, s) = rns()
	diff = r - l + 1
	lo = diff * (diff + 1) // 2
	hi = lo + diff * (n - diff)
	if lo <= s <= hi:
		ans = list(range(n - diff + 1, n + 1))
		i = 0
		sub = hi - s
		while sub > 0:
			if ans[i] == i + 1:
				i += 1
			else:
				ans[i] -= 1
				sub -= 1
		h = set(ans)
		pre = []
		suff = []
		for j in range(1, n + 1):
			if j not in h:
				if len(pre) < l - 1:
					pre.append(j)
				else:
					suff.append(j)
		print(*pre + ans + suff)
	else:
		print(-1)


from sys import stdin
input = stdin.buffer.readline
t = int(input())
for i in range(t):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	if s < k * (k + 1) // 2 or s > k * (2 * n + 1 - k) // 2:
		print(-1)
		continue
	arr = [0] * (n + 1)
	for i in range(1, k + 1):
		arr[i] = 1
	s = s - k * (k + 1) // 2
	i = k
	j = n
	while s > 0:
		x = min(s, j - i)
		arr[i + x] = 1
		arr[i] = 0
		s = s - x
		i = i - 1
		j = j - 1
	left = []
	mid = []
	right = []
	for i in range(1, n + 1):
		if arr[i] == 1:
			mid.append(i)
		elif len(left) == l - 1:
			right.append(i)
		else:
			left.append(i)
	print(*left, *mid, *right, sep=' ')


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	c = r - l + 1
	if s >= c * (c + 1) // 2 and s <= c * (2 * n - c + 1) // 2:
		sett = set()
		ss = 0
		cnt = c - 1
		for i in range(1, n + 1):
			if ss + i <= s and ss + i + cnt * (2 * n - cnt + 1) // 2 >= s:
				ss += i
				cnt -= 1
				sett.add(i)
		lst = [0] * (n + 1)
		i = l
		for j in sett:
			lst[i] = j
			i += 1
		i = v = 1
		while i <= n:
			if i < l or i > r:
				if v not in sett:
					lst[i] = v
					v += 1
					i += 1
				else:
					v += 1
			else:
				i += c
		print(*lst[1:])
	else:
		print(-1)


t = int(input())
for _ in range(t):
	(n, l, r, s) = [int(num) for num in input().strip().split(' ')]
	seq = [i for i in range(1, n + 1)]
	k = r - l + 1
	low = sum(seq[:k])
	high = sum(seq[n - k:])
	if s < low or s > high:
		print(-1)
		continue
	used = set()
	for i in reversed(seq):
		ns = s - i
		if ns < sum(seq[:k - len(used) - 1]):
			continue
		s = ns
		used.add(i)
	res = [0] * n
	l -= 1
	r -= 1
	unused = {i for i in range(1, n + 1)} - used
	for i in range(n):
		if l <= i and i <= r:
			res[i] = used.pop()
		else:
			res[i] = unused.pop()
	for i in res:
		print(i, end=' ')
	print()


def answer():
	m = r - l + 1
	v1 = n * (n + 1) // 2 - (n - m) * (n - m + 1) // 2
	v2 = m * (m + 1) // 2
	if v1 < s or v2 > s:
		return [-1]
	req = []
	taken = [False] * (n + 1)
	for i in range(1, r - l + 2):
		taken[i] = True
		req.append(i)
	need = s - sum(req)
	for i in range(len(req)):
		for v in range(n, 0, -1):
			if not taken[v] and need + req[i] - v >= 0:
				taken[v] = True
				taken[req[i]] = False
				need += req[i] - v
				req[i] = v
				break
		if need == 0:
			break
	ans = []
	for i in range(1, n + 1):
		if len(ans) == l - 1:
			ans.extend(req)
		if i not in req:
			ans.append(i)
	if len(ans) == l - 1:
		ans.extend(req)
	return ans
for T in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	print(*answer())


def fun(length, s, n):
	sum1 = 0
	lis = []
	for i in range(1, length + 1):
		lis.append(i)
		sum1 += i
	limit = n
	j = len(lis) - 1
	left = s - sum1
	while j >= 0:
		if left == 0:
			se.remove(lis[j])
			j -= 1
			continue
		if limit - lis[j] >= left:
			lis[j] += left
			se.remove(lis[j])
			j -= 1
			left = 0
		else:
			x = limit - lis[j]
			lis[j] += x
			left -= x
			se.remove(lis[j])
			j -= 1
			limit -= 1
	return lis
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	se = set()
	for i in range(1, n + 1):
		se.add(i)
	length = r - l + 1
	min1 = 0
	max1 = 0
	n2 = n
	j = 1
	for i in range(1, length + 1):
		min1 += j
		j += 1
	for j in range(length, 0, -1):
		max1 += n2
		n2 -= 1
	if s >= min1 and s <= max1:
		temp = fun(length, s, n)
	else:
		print(-1)
		continue
	l1 = []
	l2 = []
	for i in range(1, l):
		l1.append(se.pop())
	for i in range(r + 1, n + 1):
		l2.append(se.pop())
	f = l1 + temp + l2
	for i in f:
		print(i, end=' ')
	print()


for y in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	ln = r - l + 1
	if ln * (ln + 1) // 2 <= s <= n * (n + 1) // 2 - (n - ln) * (n - ln + 1) // 2:
		lst = [0] * ln
		for i in range(ln):
			lst[i] = i + 1
		s -= sum(lst)
		lst = lst + [10000000000]
		p = ln - 1
		while s > 0:
			if lst[p] < n and lst[p] + 1 < lst[p + 1]:
				lst[p] += 1
				s -= 1
			else:
				p -= 1
		vis = [0] * (n + 1)
		k = 0
		for i in range(ln):
			vis[lst[k]] = 1
			k += 1
		ans = [0] + [0] * (l - 1) + lst[:-1] + [0] * (n - r)
		k = 1
		for i in range(1, l):
			while k <= n and vis[k] == 1:
				k += 1
			ans[i] = k
			k += 1
		for i in range(r + 1, n + 1):
			while k <= n and vis[k] == 1:
				k += 1
			ans[i] = k
			k += 1
		print(*ans[1:])
	else:
		print('-1')


from collections import Counter
r = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	x = n
	arr = list(range(1, r - l + 2))
	i = -1
	need = s - sum(arr)
	if need < 0:
		print(-1)
	else:
		i = -1
		while need and abs(i) <= r - l + 1:
			z = min(need, x - arr[i])
			need -= z
			arr[i] += z
			i -= 1
			x -= 1
		if need:
			print(-1)
		else:
			x = Counter(arr)
			ans = []
			for i in range(1, n + 1):
				if not x[i]:
					ans.append(i)
			a = ans[:l - 1]
			a += arr
			a += ans[l - 1:]
			print(*a)


import io, os, sys
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, l, r, s) = [int(x) for x in input().split()]
	x = r - l + 1
	arr = [y for y in range(1, n + 1)]
	arr1 = [y for y in range(1, n + 1)]
	if sum(arr[:x]) > s:
		print(-1)
		return
	arr.reverse()
	if sum(arr[:x]) < s:
		print(-1)
		return
	arr = [y for y in range(1, x + 1)]
	cur = sum(arr)
	temp = 0
	for j in range(x - 1, -1, -1):
		while 1:
			if cur == s:
				left = []
				right = []
				uu = 0
				for i in arr1:
					if i not in arr and i not in left and (i not in right):
						if uu + 1 < l:
							left.append(i)
							uu += 1
						else:
							right.append(i)
				arr = left + arr + right
				print(*arr)
				return
			cur += 1
			arr[j] += 1
			if arr[j] == n - temp:
				temp += 1
				j -= 1
q = int(input())
for _ in range(q):
	solve()


def low(k):
	return k * (k + 1) / 2

def high(n, k):
	return k * (2 * n + 1 - k) / 2
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	minSumm = k * (k + 1) / 2
	maxSumm = k * (2 * n - k + 1) / 2
	segment = []
	used = [-1] * n
	for i in range(n, -1, -1):
		if k > 0:
			if high(i, k) >= s and s - i >= low(k - 1):
				s -= i
				k -= 1
				segment.append(i)
				used[i - 1] = 1
	unused = []
	for i in range(n):
		if used[i] != 1:
			unused.append(i + 1)
	if s != 0:
		print(-1)
		continue
	else:
		j = 0
		for i in range(n):
			if i >= l - 1 and i <= r - 1:
				print(segment[i - l + 1], end=' ')
			else:
				print(unused[j], end=' ')
				j += 1
		print()


import sys
input = sys.stdin.readline

def solve():
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	z = list(range(1, k + 1))
	t = sum(z)
	j = 0
	for i in range(k - 1, -1, -1):
		w = min(n - j - z[i], s - t)
		if w > 0:
			t += w
			z[i] += w
		j += 1
	if t != s:
		print(-1)
	else:
		w = [False] * (n + 1)
		for i in z:
			w[i] = True
		a = [None] * n
		for i in range(k):
			a[l - 1 + i] = z[i]
		j = 1
		for i in range(n):
			if a[i] is None:
				while w[j]:
					j += 1
				w[j] = True
				a[i] = j
		print(' '.join(map(str, a)))
for i in range(int(input())):
	solve()


def get_numbbbs(maximum, k, total):
	nums = list(range(1, k + 1))
	s = sum(nums)
	if s > total:
		return -1
	pointer = -1
	while s < total:
		if nums[pointer] == maximum + pointer + 1:
			pointer -= 1
		else:
			nums[pointer] += 1
			s += 1
		if -pointer > len(nums):
			return -1
	return nums
for cycle in range(int(input())):
	(n, l, r, s) = [int(x) for x in input().split()]
	a = get_numbbbs(n, r - l + 1, s)
	if a == -1:
		print(a)
	else:
		not_nuzhno = [x for x in range(1, n + 1) if x not in a]
		print(*not_nuzhno[:l - 1], *a, *not_nuzhno[l - 1:])


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]

def solve(N, L, R, S):
	n = R - L + 1
	T = []
	s = S
	n1 = n
	m = N
	while n1 > 0:
		if n1 == 1:
			if 1 <= s <= m:
				T.append(s)
			else:
				return [-1]
			n1 -= 1
		else:
			a = min(s - (n1 - 1) * n1 // 2, m)
			if n1 <= a:
				T.append(a)
				s -= a
				m = a - 1
				n1 -= 1
			else:
				return [-1]
	T_set = set(T)
	K = []
	for i in range(1, N + 1):
		if i not in T_set:
			K.append(i)
	if L == 1:
		return T + K
	elif R == N:
		return K + T
	else:
		return K[:L - 1] + T + K[L - 1:]

def main():
	T0 = int(input())
	for _ in range(T0):
		(N, L, R, S) = map(int, input().split())
		ans = solve(N, L, R, S)
		print(*ans)
main()


for _ in range(int(input())):
	(n, l, r, s) = list(map(int, input().split()))
	l -= 1
	r -= 1
	k = r - l + 1
	s1 = k * (k + 1) // 2
	s2 = k * (2 * n - k + 1) // 2
	if s < s1 or s > s2:
		print(-1)
	else:
		a = [i + 1 for i in range(n)]
		last = n
		mid = []
		while k:
			poss = s - k * (k - 1) // 2
			t = min(poss, last)
			s = s - t
			mid.append(t)
			last = last - 1
			k = k - 1
		rest = set(a) - set(mid)
		rest = list(rest)
		ans = rest[:l] + mid + rest[l:]
		print(*ans)


import math
from collections import defaultdict, Counter
import os
import sys
from io import BytesIO, IOBase
ii = lambda : int(input())
lmii = lambda : list(map(int, input().split()))
slmii = lambda : sorted(map(int, input().split()))
li = lambda : list(input())
mii = lambda : map(int, input().split())
msi = lambda : map(str, input().split())

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def main():
	for _ in ' ' * int(input()):
		(n, l, r, s) = mii()
		p = []
		for i in range(1, n + 1):
			p.append(i)
		if not sum(p[:r - l + 1]) <= s <= sum(p[-(r - l + 1):]):
			print(-1)
		else:
			low = list(p[:r - l + 1])
			cc = s - sum(low)
			md = cc % (r - l + 1)
			qq = cc // (r - l + 1)
			lv = p[r - l] + qq
			pp = list(p[:r - l + 1])
			pp[-1] = lv
			for i in range(len(pp) - 2, -1, -1):
				pp[i] = pp[i + 1] - 1
			for i in range(len(pp) - 1, -1, -1):
				if md == 0:
					break
				md -= 1
				pp[i] += 1
			ans = [0] * n
			ddd = defaultdict(int)
			for i in pp:
				ddd[i] = 1
			for i in range(n):
				if l <= i + 1 <= r:
					ans[i] = pp.pop()
			for i in range(n):
				if ans[i] == 0:
					for j in range(len(p)):
						if ddd[p[j]] == 0:
							ans[i] = p[j]
							p.remove(p[j])
							break
			print(*ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t > 0:
	t -= 1
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	smin = k * (k + 1) // 2
	smax = smin + k * (n - k)
	if smin <= s <= smax:
		dif = s - smin
		q1 = dif // k
		q2 = dif % k
		a = [i + 1 for i in range(k)]
		for i in range(k - 1, -1, -1):
			if q2 > 0:
				a[i] += q1 + 1
				q2 -= 1
			else:
				a[i] += q1
		b = set()
		for i in range(k):
			b.add(a[i])
		c = []
		for i in range(1, n + 1):
			if i not in b:
				c.append(i)
		ans = []
		y1 = 0
		y2 = 0
		for i in range(1, n + 1):
			if i < l or i > r:
				ans.append(c[y1])
				y1 += 1
			else:
				ans.append(a[y2])
				y2 += 1
		for i in range(n):
			print(ans[i], end=' ')
		print()
	else:
		print(-1)


(T,) = map(int, input().split())
for _ in range(T):
	(n, l, r, s) = map(int, input().split())
	x = list(range(1, r - l + 2))
	mx = sum(range(n - (r - l), n + 1))
	mn = sum(x)
	if s > mx or s < mn:
		print(-1)
		continue
	c = -1
	for _ in range(s - mn):
		if c == -1:
			if x[c] != n:
				x[c] += 1
				continue
			else:
				c -= 1
				x[c] += 1
				continue
		if x[c] != x[c + 1] - 1:
			x[c] += 1
		else:
			c -= 1
			x[c] += 1
	tmp = [0] * (n + 1)
	for c in x:
		tmp[c] += 1
	R = [0] * (n + 1)
	c = 1
	for i in range(1, n + 1):
		while c < n + 1 and tmp[c] == 1:
			c += 1
		if i < l or r < i:
			R[i] = c
			tmp[c] = 1
		else:
			R[i] = x[i - l]
	print(*R[1:])


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from collections import defaultdict, Counter
t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	min_sum = k * (k + 1) // 2
	max_sum = k * (2 * n - k + 1) // 2
	visited = [False] * (n + 1)
	ans = []
	for i in range(k):
		ans.append(i + 1)
	ans.sort(reverse=True)
	maxes = []
	for i in range(n, 0, -1):
		maxes.append(i)
	cur_sum = sum(ans)
	for i in range(k):
		if cur_sum >= s:
			break
		diff = maxes[i] - ans[i]
		if cur_sum + diff <= s:
			ans[i] += diff
			cur_sum += diff
		else:
			ans[i] += s - cur_sum
			cur_sum += s - cur_sum
			break
	if sum(ans) == s:
		for x in ans:
			visited[x] = True
		left = []
		right = []
		for i in range(1, n + 1):
			if len(left) == l - 1:
				break
			if not visited[i]:
				left.append(i)
				visited[i] = True
		for i in range(1, n + 1):
			if len(right) == n - r:
				break
			if not visited[i]:
				right.append(i)
				visited[i] = True
		r = left + ans + right
		print(' '.join(map(str, r)))
	else:
		print(-1)


def solve(n, lft, r, s):
	l = r - lft + 1
	arr = [i for i in range(1, l + 1)]
	sm = l * (l + 1) // 2
	if s < sm:
		return -1
	if s > sm:
		x = (s - sm) // l
		xm = s - (x * l + sm)
		if x + arr[-1] > n:
			return -1
		if x + arr[-1] == n:
			if xm != 0:
				return -1
		for i in range(l):
			arr[i] += x
			sm += x
		for i in range(l - 1, -1, -1):
			if s == sm:
				break
			arr[i] += 1
			sm += 1
	la = []
	for i in range(1, n + 1):
		if i not in arr:
			la.append(i)
	lst = []
	cn = 0
	ca = 0
	b = 0
	for i in range(1, n + 1):
		if i == lft:
			b = 1
		if b == 0:
			lst.append(la[cn])
			cn += 1
		else:
			lst.append(arr[ca])
			ca += 1
		if i == r:
			b = 0
	return lst
t = int(input())
for i in range(t):
	(n, l, r, s) = map(int, input().split(' '))
	x = solve(n, l, r, s)
	if x == -1:
		print(-1)
	else:
		print(*x)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	c = r - l + 1
	sp = []
	f = range(n - c + 1, n + 1)
	h = range(1, c + 1)
	max_s = sum(f)
	min_s = sum(h)
	if s > max_s or s < min_s:
		print(-1)
	elif s == min_s:
		c = list(range(1, n + 1))
		for el in h:
			c.remove(el)
		j = 0
		k = 0
		for i in range(n):
			if i < l - 1:
				sp.append(c[j])
				j += 1
			elif i > r - 1:
				sp.append(c[j])
				j += 1
			else:
				sp.append(h[k])
				k += 1
		print(*sp)
	elif s == max_s:
		c = list(range(1, n + 1))
		for el in f:
			c.remove(el)
		j = 0
		k = 0
		for i in range(n):
			if i < l - 1:
				sp.append(c[j])
				j += 1
			elif i > r - 1:
				sp.append(c[j])
				j += 1
			else:
				sp.append(f[k])
				k += 1
		print(*sp)
	else:
		g = max_s - s
		f = list(f)
		while sum(f) > s:
			for i in range(c):
				f[i] -= 1
		i = -1
		while sum(f) < s:
			f[i] += 1
			i -= 1
		c = list(range(1, n + 1))
		for el in f:
			c.remove(el)
		j = 0
		k = 0
		for i in range(n):
			if i < l - 1:
				sp.append(c[j])
				j += 1
			elif i > r - 1:
				sp.append(c[j])
				j += 1
			else:
				sp.append(f[k])
				k += 1
		print(*sp)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	c = 1
	f = []
	for i in range(l, r + 1):
		f.append(c)
		c += 1
	ll = r - l + 1
	k = 0
	i = ll - 1
	while True:
		if sum(f) == s:
			break
		if f[i] > n:
			k = 1
			break
		f[i] += 1
		i -= 1
		i %= ll
	if k:
		print(-1)
	else:
		ans = []
		c = 0
		aa = []
		kk = 0
		for i in range(1, n + 1):
			if i not in f:
				ans.append(i)
		for i in range(n):
			if i >= l - 1 and i < r:
				aa.append(f[c])
				c += 1
			else:
				aa.append(ans[kk])
				kk += 1
		k = 0
		for i in range(n):
			if aa[i] > n:
				k = 1
		if k:
			print(-1)
			continue
		print(*aa)


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, l, r, s) = map(int, input().split())
		z = r - l + 1
		if s < z * (z + 1) // 2 or s > (n * (n + 1) - (n - z) * (n - z + 1)) // 2:
			print(-1)
		else:
			a = [i for i in range(1, r - l + 2)]
			(su, b) = (sum(a), set(a))
			for i in range(len(a) - 1, -1, -1):
				su -= a[i]
				(z, f) = (s - su, 1)
				for j in range(min(n, z), a[i], -1):
					if j not in b and j <= z:
						b.discard(a[i])
						(a[i], su, f) = (j, su + j, 0)
						b.add(j)
						break
				if f:
					su += a[i]
			ans = []
			for i in range(1, n + 1):
				if i not in b:
					ans.append(i)
			print(*ans[:l - 1] + a + ans[l - 1:])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
stdin.readline

def mp():
	return list(map(int, stdin.readline().strip().split()))

def it():
	return int(stdin.readline().strip())
from collections import defaultdict as dd, Counter as C, deque
from math import ceil, gcd, sqrt, factorial
from itertools import permutations

def solve():
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	z = list(range(1, k + 1))
	t = sum(z)
	j = 0
	if s < t or s > n * (n + 1) // 2:
		print(-1)
		return
	for i in range(k - 1, -1, -1):
		w = min(n - j - z[i], s - t)
		if w > 0:
			t += w
			z[i] += w
		j += 1
	if t != s:
		print(-1)
	else:
		w = [False] * (n + 1)
		for i in z:
			w[i] = True
		a = [None] * n
		for i in range(k):
			a[l - 1 + i] = z[i]
		j = 1
		for i in range(n):
			if a[i] is None:
				while w[j]:
					j += 1
				w[j] = True
				a[i] = j
		print(*a)
for _ in range(it()):
	solve()


t = int(input())
for _ in range(t):
	(n, l, r, s) = (int(i) for i in input().split())
	nums = r - l + 1
	mins = (nums + 1) * nums // 2
	maxs = (n + n - nums + 1) * nums // 2
	if s < mins or s > maxs:
		print(-1)
		continue
	lst = list(range(1, nums + 1))
	d = s - mins
	i = 1
	maxnum = n
	while d:
		add = d if maxnum - lst[nums - i] > d else maxnum - lst[nums - i]
		lst[nums - i] += add
		d -= add
		i += 1
		maxnum -= 1
	used = set(lst)
	counter = 1
	for i in range(1, n + 1):
		if i < l or i > r:
			while counter in used:
				counter += 1
			print(counter, end=' ')
			counter += 1
		else:
			print(lst[i - l], end=' ')
	print()


import collections

def permutationbysum():
	for _ in range(int(input())):
		(num, l, r, achieve) = map(int, input().split())
		k = r - l + 1
		if k * (k + 1) // 2 <= achieve <= k * (num * 2 + 1 - k) // 2:
			outpos = r % num
			inpos = l - 1
			ans = [0] * num
			for i in range(num, 0, -1):
				if achieve - i > 0 or (achieve - i == 0 and inpos == r - 1):
					achieve -= i
					ans[inpos] = i
					inpos += 1
				else:
					ans[outpos] = i
					outpos += 1
					outpos %= num
			print(*ans)
		else:
			print(-1)

def peaks():
	for _ in range(int(input())):
		(num, peak) = map(int, input().split())
		pos = 1
		rpos = num
		ans = []
		now = 0
		if num == 1:
			if not peak:
				print(1)
			else:
				print(-1)
			continue
		if num == 2:
			if peak:
				print(-1)
			else:
				print(1, 2)
			continue
		added = 0
		while rpos + 1 != pos:
			if not peak:
				while pos <= rpos:
					ans.append(pos)
					pos += 1
				break
			if not now:
				ans.append(pos)
				pos += 1
			else:
				ans.append(rpos)
				rpos -= 1
				if num - added != 1:
					peak -= 1
			added += 1
			now = 1 - now
		if peak:
			print(-1)
			continue
		print(*ans)
import sys
input = sys.stdin.readline

def addone():
	for _ in range(int(input())):
		(num, changes) = input().split()
		l = collections.deque(sorted([int(i) for i in num]))
		perm = collections.deque()
		changes = int(changes)
		cd = 0
		ans = len(num)
		while True:
			nextnum = l.pop()
			while perm and perm[-1] == nextnum:
				l.append(perm.pop())
			c = 10 - nextnum - cd
			changes -= c
			cd += c
			if changes >= 0:
				if not c:
					perm.appendleft(1 - cd)
					l.appendleft(-cd)
				else:
					l.appendleft(1 - cd)
					l.appendleft(-cd)
				ans += 1
			else:
				break
		print(ans % 1000000007)
import math

def andsequences():

	def mapping(num):
		nonlocal mnum
		nonlocal c
		num = int(num)
		if num < mnum:
			mnum = num
			c = 1
		elif num == mnum:
			c += 1
		return num
	mod = 1000000007
	for _ in range(int(input())):
		mnum = float('inf')
		c = 0
		num = int(input())
		l = list(map(mapping, input().split()))
		for i in l:
			if mnum & i != mnum:
				print(0)
				break
		else:
			if c == 1:
				print(0)
			else:
				print(math.factorial(num - 2) * (c - 1) * c % mod)

def numberdigit():
	n = 10 ** 5 * 2
	l = [0] * 11
	mod = 10 ** 9 + 7
	l[0] = l[1] = l[2] = l[3] = l[4] = l[5] = l[6] = l[7] = l[8] = 2
	l[9] = 3
	l[10] = 4
	for i in range(11, n):
		l.append((l[i - 10] + l[i - 9]) % mod)
	for _ in range(int(input())):
		(num, c) = input().split()
		c = int(c)
		ans = 0
		for i in num:
			i = int(i)
			if 10 - i > c:
				ans += 1
			else:
				ans += l[c - (10 - i)]
		print(ans % mod)

def mushroom():
	(people, t1, t2, percent) = map(int, input().split())
	l = []
	percent = 1 - percent * 0.01
	for i in range(1, people + 1):
		(s, s1) = map(int, input().split())
		l.append([i, max(s * t1 * percent + s1 * t2, s1 * t1 * percent + s * t2)])
	l.sort(key=lambda x: x[1], reverse=True)
	for i in l:
		i[1] = '{:.2f}'.format(i[1])
		print(*i)

def escape():
	prins = int(input())
	dra = int(input())
	start = int(input())
	pack = int(input())
	c = int(input())
	speeddiff = dra - prins
	if speeddiff <= 0:
		return 0
	pd = start * prins
	ans = 0
	while pd < c:
		hs = pd / speeddiff
		pd += prins * hs
		if pd >= c:
			break
		time = pd / dra
		time += pack
		pd += prins * time
		ans += 1
	return ans

def perm():

	def high(n, k):
		return k * (2 * n - k + 1) // 2

	def low(k):
		return k * (k + 1) // 2
	for _ in range(int(input())):
		(num, lef, rig, s) = map(int, input().split())
		k = rig - lef + 1
		(rig, lef) = (rig - 1, lef - 1)
		if not high(num, k) >= s >= low(k):
			print(-1)
			continue
		l = [0] * num
		lp = lef
		rp = lef - 1
		for i in range(num, 0, -1):
			if high(i, k) >= s and s - i >= low(k - 1) and k:
				l[lp] = i
				lp += 1
				s -= i
				k -= 1
			else:
				l[rp] = i
				rp -= 1
		if k:
			print(-1)
		else:
			print(*l)
perm()


from collections import *

def allGood(perm):
	if sum(perm[l:r + 1]) != s:
		return False
	d = defaultdict(int)
	for i in range(n):
		d[perm[i]] += 1
	if max(d.values()) > 1:
		return False
	if max(d.keys()) > n:
		return False
	if min(d.keys()) <= 0:
		return False
	return True
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	another = [i for i in range(n, 0, -1)]
	l -= 1
	r -= 1
	perm = [0] * n
	vis = [False] * (n + 1)
	elem = r - l + 1
	can_get = sum(another[:elem])
	if s > can_get:
		print(-1)
	else:
		curr = 1
		sum_ele = 0
		flag = False
		for i in range(l, r):
			sum_ele += curr
			perm[i] = curr
			curr += 1
			if perm[i] > n:
				print(-1)
				break
		else:
			perm[r] = s - sum_ele
			if perm[r] > n:
				diff = perm[r] - n
				perm[r] = n
				flag = True
			if flag:
				minus = 1
				for i in range(r - 1, l - 1, -1):
					if diff <= 0:
						break
					if perm[i] + diff > n - minus:
						prev = perm[i]
						perm[i] = n - minus
						minus += 1
						diff -= perm[i] - prev
					else:
						perm[i] = perm[i] + diff
						diff = 0
			for i in range(n):
				vis[perm[i]] = True
			arr = [i for i in range(1, n + 1)]
			idx = 0
			for i in range(n):
				if perm[i] == 0:
					while idx < n and vis[arr[idx]] == True:
						idx += 1
					if idx == n:
						break
					perm[i] = arr[idx]
					vis[arr[idx]] = True
			if allGood(perm) == False:
				print(-1)
			else:
				print(*perm)


class Solution:

	def get_n_sum(self, n):
		return n * (n + 1) // 2

	def get_last_n_sum(self, n, k):
		return k * (2 * n + 1 - k) // 2

	def solve(self, n, l, r, s):
		nsum = self.get_n_sum(n)
		if s > nsum:
			return -1
		k = r - l + 1
		low = self.get_n_sum(k)
		high = self.get_last_n_sum(n, k)
		if s < low or s > high:
			return -1
		result = [-1 for _ in range(n)]
		lr_set = set()
		count = l - 1
		for i in range(n, 0, -1):
			if k > 0:
				k_ = k - 1
				high = k * (2 * i + 1 - k) // 2
				low = k_ * (k_ + 1) // 2
				if high >= s and s - i >= low:
					result[count] = i
					lr_set.add(i)
					count += 1
					s -= i
					k -= 1
		count = 1
		for i in range(n):
			if result[i] == -1:
				while True:
					if count in lr_set:
						count += 1
					else:
						break
				result[i] = count
				count += 1
		return ' '.join((str(r) for r in result))
sol = Solution()
tests = int(input())
results = []
for _ in range(tests):
	(n, l, r, s) = list(map(int, input().split()))
	result = sol.solve(n, l, r, s)
	results.append(result)
for result in results:
	print(result)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict, Counter

def ceil(a, b):
	return (a + b - 1) // b
for _ in range(ri()):
	(n, l, r, s) = ria()
	x = r - l + 1
	z = []
	s1 = 0
	for i in range(1, x + 1):
		z.append(i)
		s1 += i
	if s1 > s:
		print(-1)
		continue
	ans = [0 for i in range(n)]
	q = [0 for i in range(n + 1)]
	e = len(z)
	flag = 0
	i = e - 1
	while s1 != s:
		z[i] += 1
		s1 += 1
		if z[i] > n:
			flag = 1
			break
		if s1 == s:
			break
		i -= 1
		if i < 0:
			i = e - 1
	j = 0
	if flag:
		print(-1)
		continue
	for i in range(l - 1, r):
		ans[i] = z[j]
		q[ans[i]] = 1
		j += 1
	i = 0
	j = 1
	asd = []
	for i in range(1, n + 1):
		if q[i] == 0:
			asd.append(i)
	i = 0
	for j in range(n):
		if ans[j] == 0:
			ans[j] = asd[i]
			i += 1
	print(*ans)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	a = [i + 1 for i in range(n)]
	d = r - l + 1
	low = sum(a[:d])
	high = sum(a[-d:])
	if s > high or s < low:
		print(-1)
	else:
		t = a[-d:]
		x = 0
		for i in range(d):
			if high - s > 0:
				if t[i] - (i + 1) <= high - s:
					high -= t[i] - (i + 1)
					t[i] = i + 1
				else:
					t[i] -= high - s
					break
			else:
				break
		check = [False] * (n + 1)
		ans = [0] * n
		j = 0
		for i in range(l - 1, r):
			ans[i] = t[j]
			check[t[j]] = True
			j += 1
		j = 1
		for i in range(n):
			if ans[i] == 0:
				while check[j]:
					j += 1
				ans[i] = j
				check[j] = True
		print(*ans)


import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
mod = 1000000007

def factorial(a):
	ans = 1
	for i in range(1, a + 1):
		ans = ans * i % mod
	return ans
for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	(an1, an2) = (0, 0)
	for i in range(1, r - l + 2):
		an1 += i
	for i in range(0, r - l + 1):
		an2 += n - i
	if s > an2 or s < an1:
		print(-1, end=' ')
	else:
		(i, ans) = (0, 0)
		lis = []
		for i in range(1, r - l + 1 + 1):
			lis.append(i)
			ans += i
		if ans != s:
			i = -1
			while ans != s:
				if lis[i] == n + i + 1:
					i -= 1
				else:
					lis[i] += 1
					ans += 1
		j = 0
		s = set()
		for ii in lis:
			s.add(ii)
		ii = 1
		for i in range(1, n + 1):
			if i >= l and i <= r:
				print(lis[j], end=' ')
				j += 1
			else:
				while ii in s:
					ii += 1
				print(ii, end=' ')
				s.add(ii)
	print()


import math

def cumul_1_up_to(n):
	return n * (n + 1) // 2
t = int(input())
for _ in range(t):
	(n, l, r, s) = list(map(int, input().split(' ')))
	if n == 1:
		print(*[1])
	else:
		sum1 = cumul_1_up_to(r - l + 1)
		sum2 = cumul_1_up_to(n) - cumul_1_up_to(n - (r - l) - 1)
		if s < sum1 or s > sum2:
			print(-1)
		else:
			m = r - l + 1
			k = math.floor((s - sum1) / m)
			a = [i + 1 + k for i in range(m)]
			sum_a = sum1 + k * m
			C = s - sum_a
			for i in range(C):
				a[-1 - i] += 1
			ans = [-1 for _ in range(n)]
			for i in range(m):
				ans[l - 1 + i] = a[i]
			S = set(range(1, n + 1))
			S.difference_update(set(ans))
			S = list(S)
			for i in range(n):
				if ans[i] == -1:
					new = S.pop()
					ans[i] = new
			print(*ans)


from sys import stdin, stderr
input = stdin.readline

def dbp(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def get_int_list():
	return [int(x) for x in input().strip().split()]

def do_thing():
	(n, l, r, s) = get_int_list()
	l -= 1
	r -= 1
	sec = []
	for i in range(1, r - l + 2):
		sec.append(i)
	secsum = sum(sec)
	if secsum > s:
		return -1
	gap = s - secsum
	(step, m) = divmod(gap, len(sec))
	for i in range(len(sec)):
		if i < len(sec) - m:
			sec[i] += step
		else:
			sec[i] += step + 1
	if sec[-1] > n:
		return -1
	taken = set(sec)
	remains = [i for i in range(1, n + 1) if i not in taken]
	return ' '.join((str(x) for x in remains[:l] + sec + remains[l:]))

def multicase():
	maxcc = int(input().strip())
	for cc in range(maxcc):
		print(do_thing())
multicase()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	if x * (x + 1) // 2 > s:
		print(-1)
	elif n * (n + 1) / 2 - (n - x) * (n - x + 1) / 2 < s:
		print(-1)
	else:
		ans = [0 for i in range(n)]
		i = n
		j = l - 1
		while j < r:
			tt = x * (x - 1) / 2 + i
			if tt < s:
				s -= i
				ans[j] = i
				x -= 1
				i -= 1
				j += 1
			elif tt == s:
				ans[j] = i
				i = 1
				j += 1
				while j < r:
					ans[j] = i
					j += 1
					i += 1
			else:
				i -= 1
		s = set(ans)
		i = 0
		j = 1
		while i < n:
			if ans[i] != 0:
				i += 1
			elif j in s:
				j += 1
			else:
				ans[i] = j
				i += 1
				j += 1
		print(*ans)


t = int(input())
for _ in range(t):
	(n, l, r, s) = list(map(int, input().split()))
	els = []
	sels = 0
	nb = r - l + 1
	els = [i + 1 for i in range(nb)]
	sels = (nb + 1) * nb // 2
	if sels > s:
		print(-1)
		continue
	i = len(els) - 1
	while sels < s and i >= 0:
		if sels + (n - nb) < s:
			els[i] += n - nb
			sels += n - nb
		else:
			delta = s - sels
			els[i] += delta
			sels = s
		i -= 1
	if sels < s:
		print(-1)
		continue
	j = 1
	k = 0
	for i in range(1, n + 1):
		if i < l or i > r:
			while j in els:
				j += 1
			print(j, end=' ')
			j += 1
		else:
			print(els[k], end=' ')
			k += 1
	print()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for case in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	positions = r - l + 1
	base = [*range(1, positions + 1)]
	sb = sum(base)
	target = s
	remaining = target - sb
	for i in range(positions - 1, -1, -1):
		if i == positions - 1:
			max_value = n
		else:
			max_value = base[i + 1] - 1
		if remaining + base[i] <= max_value:
			base[i] += remaining
			remaining = 0
			sb += remaining
		else:
			remaining -= max_value - base[i]
			sb += max_value - base[i]
			base[i] = max_value
	others = [-1] * (n - (r - l + 1))
	(k, j) = (0, 0)
	for i in range(1, n + 1):
		if j < len(base) and base[j] == i:
			j += 1
		elif k < len(others):
			others[k] = i
			k += 1
	if l != 1:
		ans = others[:l - 1] + base + others[l - 1:]
	else:
		ans = base + others
	ans_copy = ans.copy()
	ans_copy.sort()
	val = 1
	for i in ans_copy:
		if i != val:
			ans = [-1]
		else:
			val += 1
	if ans[0] != -1:
		if sum(ans[l - 1:r]) != s:
			ans = [-1]
	print(*ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
from collections import deque
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		(n, l, r, s) = map(int, input().split())
		p = [x for x in range(1, n + 1)]
		ss = set(p)
		(mn, mx) = ([], [])
		v = r - l + 1
		for j in range(v):
			mn.append(p[j])
		for j in range(n - v, n):
			mx.append(p[j])
		if s < sum(mn) or s > sum(mx):
			print(-1)
			continue
		ans = [0] * n
		index = 0
		for j in range(l, r + 1):
			ans[j - 1] = mn[index]
			index += 1
		x = s - sum(mn)
		while x > 0:
			for j in range(r, l - 1, -1):
				ans[j - 1] += 1
				x -= 1
				if x == 0:
					break
		for j in range(l, r + 1):
			ss.remove(ans[j - 1])
		tt = list(ss)
		for j in range(n):
			if ans[j - 1] == 0:
				ans[j - 1] = tt[-1]
				tt.pop()
		print(' '.join([str(a) for a in ans]))
main()


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	z = n
	k = r - l + 1
	if s < (k * k + k) // 2 or s > k * (2 * n + 1 - k) // 2:
		print(-1)
	else:
		a = []
		s -= (k * k + k) // 2
		for i in range(k, 0, -1):
			a.append(i)
		i = 0
		while s > 0:
			m = min(n - a[i], s)
			s -= m
			n -= 1
			a[i] += m
			i += 1
		d = {i: 0 for i in range(1, 1 + z)}
		for i in a:
			d[i] = 1
		ans = []
		b = [i for i in d if d[i] == 0]
		ans = b[:l - 1]
		ans.extend(a)
		ans.extend(b[l - 1:])
		print(*ans)


for w in range(int(input())):
	(n, left, right, s) = tuple(map(int, input().split()))
	length = right - left + 1
	l = [i + 1 for i in range(n)]
	temp = 0
	keys = []
	ans = [-1] * n
	for i in range(length):
		temp += l[i]
		keys.append(i)
	pointer = length - 1
	k = keys[pointer]
	final = n
	while temp < s and pointer >= 0:
		while temp < s and k + 1 < final:
			keys[pointer] += 1
			k += 1
			temp += 1
		if temp == s:
			break
		final = k
		pointer -= 1
		if pointer >= 0:
			k = keys[pointer]
	if left == right:
		if s > n:
			print(-1)
		else:
			ans[left - 1] = s
			count = 1
			for i in range(n):
				if i != left - 1:
					if count == s:
						count += 1
					ans[i] = count
					count += 1
			for i in range(n):
				print(ans[i], end=' ')
			print()
	elif temp < s or temp > s:
		print(-1)
	else:
		count = 0
		d = {}
		for i in range(left - 1, right):
			ans[i] = l[keys[count]]
			d[l[keys[count]]] = 1
			count += 1
		count = 1
		for i in range(n):
			if i < left - 1 or i >= right:
				if count not in d:
					ans[i] = count
					count += 1
				else:
					while count in d:
						count += 1
					ans[i] = count
					count += 1
		for i in range(n):
			print(ans[i], end=' ')
		print()


import sys
import math
import bisect
import functools
from functools import lru_cache
from sys import stdin, stdout
from math import gcd, floor, sqrt, log, ceil
from heapq import heappush, heappop, heapify
from collections import defaultdict as dd
from collections import Counter as cc
from bisect import bisect_left as bl
from bisect import bisect_right as br

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
sys.setrecursionlimit(100000000)
intinp = lambda : int(input().strip())
stripinp = lambda : input().strip()
fltarr = lambda : list(map(float, input().strip().split()))
intarr = lambda : list(map(int, input().strip().split()))
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
MOD = 1000000007
num_cases = intinp()
for _ in range(num_cases):
	(n, l, r, s) = intarr()
	d = []
	ps = 0
	si = r - l + 1
	for i in range(r - l + 1):
		ps += n - i
		d.append(n - i)
	if ps < s or s < si * (si + 1) / 2:
		print(-1)
		continue
	i = 0
	d.reverse()
	while ps != s:
		ps -= 1
		d[i] -= 1
		i = (i + 1) % si
	p = d
	seen = set(p)
	ne = []
	for i in range(1, n + 1):
		if i not in seen:
			ne.append(i)
	p = ne[:l - 1] + p + ne[l - 1:]
	for v in p:
		print(v, end=' ')
	print()


def get(sum, dist, n):
	if not (dist + 1) * dist / 2 <= sum <= (2 * n - dist + 1) * dist / 2:
		return None
	ans = []
	for cur in range(n, 0, -1):
		if dist * (dist - 1) / 2 + cur <= sum:
			ans.append(cur)
			sum -= cur
			dist -= 1
	return ans
t = int(input())
for _ in range(t):
	(n, l, r, s) = [int(x) for x in input().split()]
	dist = r - l + 1
	ans = get(s, dist, n)
	if ans is None:
		print(-1)
	else:
		rest = list(set(range(1, n + 1)) - set(ans))
		total = [str(x) for x in rest[:l - 1] + ans + rest[l - 1:]]
		print(' '.join(total))


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, l, r, s) = value()
	need = r - l + 1
	per = [i for i in range(1, n + 1)]
	ans = per[:need]
	if s < sum(ans) or s > sum(per[-need:]):
		print(-1)
	else:
		have = sum(ans)
		i = len(ans) - 1
		last = per[-need:]
		while have != s:
			while have < s and ans[i] < last[i]:
				ans[i] += 1
				have += 1
			i -= 1
		extra = [i for i in per if i not in ans]
		print(*extra[:l - 1], *ans, *extra[l - 1:])


for _ in ' ' * int(input()):
	(n, l, r, s) = map(int, input().split())
	if n * (n + 1) // 2 - (n - r + l - 1) * (n - r + l) // 2 < s:
		print(-1)
		continue
	if (r - l + 1) * (r - l + 2) // 2 > s:
		print(-1)
		continue
	x = n
	add = [i + 1 for i in range(r - l + 1)]
	sa = sum(add)
	ind = 0
	while True:
		if sa == s:
			break
		if add[r - l - ind] != n - ind:
			add[r - l - ind] += 1
			sa += 1
		else:
			ind += 1
		if ind >= n:
			break
	if sum(add) != s:
		print(-1)
		continue
	al = [i + 1 for i in range(n)]
	puti = sorted(add)[::-1]
	perm = [0] * n
	for i in range(l, r + 1):
		perm[i - 1] = puti.pop(0)
		del al[perm[i - 1] - 1]
	for i in range(n):
		if not perm[i]:
			perm[i] = al.pop()
	print(*perm)


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	t = [i for i in range(1, x + 1)]
	b = True
	if sum(t) > s:
		b = False
		print(-1)
	else:
		s -= sum(t)
		to_add = s // x
		for i in range(x):
			t[i] += to_add
		to_add = s % x
		i = x - 1
		while to_add:
			t[i] += 1
			to_add -= 1
			i -= 1
		for i in t:
			if i > n:
				b = False
				break
		if len(set(t)) < len(t):
			b = False
		if not b:
			print(-1)
		else:
			ans = [0] * n
			c = 0
			v = set([i for i in range(1, n + 1)])
			for i in range(l - 1, r):
				ans[i] = t[c]
				c += 1
				v.discard(ans[i])
			v = list(v)
			for i in range(n):
				if ans[i] == 0:
					ans[i] = v.pop()
			print(*ans)


import sys, functools, collections, bisect, math, heapq
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().strip().split())

	def high(i, k):
		return k * (2 * i + 1 - k) // 2

	def low(k):
		return k * (k + 1) // 2
	arr = set()
	k = r - l + 1
	for i in range(n, 0, -1):
		if k > 0 and high(i, k) >= s and (s - i >= low(k - 1)):
			arr.add(i)
			k -= 1
			s -= i
	if s > 0:
		print(-1)
	else:
		brr = set(range(1, n + 1))
		brr.difference_update(arr)
		a = [0] * n
		for i in range(l - 1, r):
			a[i] = arr.pop()
		for i in range(n):
			if a[i] == 0:
				a[i] = brr.pop()
		print(' '.join((str(i) for i in a)))


for i in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	re = n * (n + 1) // 2
	t = r - l + 1
	b = [0] * n
	a = [0] * (r - l + 1)
	su = 0
	d = dict()
	d1 = dict()
	for i in range(1, n + 1):
		d[i] = 0
		d1[i] = 0
	f = 0
	for i in range(0, r - l + 1):
		a[i] = i + 1
		su += i + 1
	if s > re or su > s:
		f = 1
	elif su == s:
		for i in range(l - 1, r):
			d[a[i - l + 1]] = 1
			b[i] = a[i - l + 1]
		val = 1
		for i in range(n):
			if i < r and i >= l - 1:
				continue
			while d[val]:
				val += 1
			b[i] = val
			d[val] = 1
			if b[i] > n:
				f = 1
				break
	else:
		while su < s:
			for i in range(t - 1, -1, -1):
				if s - su > 0:
					s -= 1
					a[i] += 1
					if a[i] > n:
						f = 1
				else:
					break
		d1[1] = 0
		for i in range(l - 1, r):
			b[i] = a[i - l + 1]
			d1[a[i - l + 1]] = 1
		val1 = 1
		for i in range(0, n):
			if i < r and i >= l - 1:
				continue
			while d1[val1]:
				val1 += 1
			b[i] = val1
			d1[val1] = 1
			if b[i] > n:
				f = 1
				break
	if f == 1:
		print(-1)
	else:
		print(*b)


def out(ans, n):
	num = [i for i in range(1, n + 1) if i not in ans]
	for i in range(n):
		if ans[i] == 0:
			ans[i] = num.pop()
	print(' '.join(map(str, ans)))
t = int(input())
for _ in range(t):
	(n, l, r, s) = [int(x) for x in input().split(' ')]
	ans = [0] * n
	ex = r - l + 1
	low = ex * (ex + 1) // 2
	high = 0
	lst = n
	for i in range(ex):
		high += lst
		lst -= 1
	if s < low or s > high:
		print(-1)
		continue
	lst = 1
	tot = 0
	for i in range(l - 1, r):
		ans[i] = lst
		lst += 1
		tot += ans[i]
	pos = r - 1
	nxt = n
	while tot != s:
		if ans[pos] == nxt:
			nxt -= 1
			pos -= 1
		ans[pos] += 1
		tot += 1
	out(ans, n)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, a, b, total) = mp()
	s = set(range(1, n + 1))
	ele = b - a + 1
	if total < ele * (ele + 1) // 2:
		pr(-1)
		return
	nsum = n * (n + 1) // 2
	left = n - ele
	leftsum = left * (left + 1) // 2
	have = nsum - leftsum
	if total > have:
		pr(-1)
		return
	cur = []
	i = n
	while total:
		w = total - i
		if w >= ele * (ele - 1) // 2:
			cur.append(i)
			total -= i
			s.discard(i)
			ele -= 1
		i -= 1
	l = []
	for i in range(a - 1):
		p = max(s)
		s.discard(p)
		l.append(p)
	for i in range(b + 1, n + 1):
		p = max(s)
		s.discard(p)
		cur.append(p)
	l += cur
	print(*l)
for _ in range(inp()):
	solve()


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, l, r, s) = map(int, input().split())
	k = r - l + 1
	vals = [i for i in range(1, k + 1)][::-1]
	sigma = sum(vals)
	if sigma > s:
		print(-1)
		continue
	ptr = -1
	last = n
	while sigma < s:
		ptr += 1
		if ptr == k:
			break
		delta = min(s - sigma, last - vals[ptr])
		vals[ptr] += delta
		sigma += delta
		last -= 1
	if sigma < s:
		print(-1)
		continue
	ans = [-1 for i in range(n)]
	ans[l - 1:r] = vals
	left = []
	vals = set(vals)
	for i in range(1, n + 1):
		if i not in vals:
			left.append(i)
	ptr = -1
	for i in range(n):
		if i < l - 1 or i >= r:
			ptr += 1
			ans[i] = left[ptr]
	print(*ans)
	assert sum(ans[l - 1:r]) == s
	assert len(ans) == n
	assert sorted(ans) == [i for i in range(1, n + 1)]


for _ in range(int(input())):
	(n, l, r, s) = map(int, input().split())
	x = r - l + 1
	f = 0
	ai = []
	for i in range(x):
		ai.append(i + 1)
	if sum(ai) > s:
		print(-1)
	else:
		k = (s - sum(ai)) // x
		y = (s - sum(ai)) % x
		for i in range(x):
			ai[i] = ai[i] + k
		for i in range(y):
			ai[x - i - 1] = ai[x - i - 1] + 1
		for i in range(x):
			if ai[i] > n - r + l + i:
				f = 1
				break
		if f == 1:
			print(-1)
		else:
			li = [1] * (n + 1)
			for ele in ai:
				li[ele] = 0
			ki = []
			for i in range(1, n + 1):
				if li[i] != 0:
					ki.append(i)
			li = ki[:l - 1] + ai + ki[l - 1:]
			print(*li)


def question5():
	(Length, Left, Right, sum_from_l_r) = map(int, input().split())
	sub_length = Right - Left + 1
	remain = Length - sub_length
	if sub_length * (sub_length + 1) // 2 <= sum_from_l_r <= Length * (Length + 1) // 2 - remain * (remain + 1) // 2:
		initial = [i for i in range(1, sub_length + 1)]
		sum_initial = sum(initial)
		last = Length
		last_sub = len(initial) - 1
		sum_left = sum_from_l_r - sum_initial
		while sum_initial < sum_from_l_r:
			if last - initial[last_sub] >= sum_left:
				initial[last_sub] += sum_left
				sum_initial += sum_left
				break
			else:
				sum_left -= last - initial[last_sub]
				sum_initial += last - initial[last_sub]
				initial[last_sub] = last
			last -= 1
			last_sub -= 1
		avail_in_l_r = [False for i in range(Length + 1)]
		for i in range(len(initial)):
			avail_in_l_r[initial[i]] = True
		answer = []
		j = 1
		in_it = 0
		for i in range(1, Length + 1):
			if Left <= i <= Right:
				answer.append(initial[in_it])
				in_it += 1
			else:
				while True:
					if not avail_in_l_r[j]:
						answer.append(j)
						j += 1
						break
					else:
						j += 1
		return answer
	else:
		return -1
remained_test_cases = int(input())
while remained_test_cases > 0:
	ans = question5()
	if ans == -1:
		print(-1)
	else:
		print(*ans)
	remained_test_cases -= 1