You have a sequence $a$ with $n$ elements $1, 2, 3, \dots, k - 1, k, k - 1, k - 2, \dots, k - (n - k)$ ($k \le n < 2k$).

Let's call as inversion in $a$ a pair of indices $i < j$ such that $a[i] > a[j]$.

Suppose, you have some permutation $p$ of size $k$ and you build a sequence $b$ of size $n$ in the following manner: $b[i] = p[a[i]]$.

Your goal is to find such permutation $p$ that the total number of inversions in $b$ doesn't exceed the total number of inversions in $a$, and $b$ is lexicographically maximum.

Small reminder: the sequence of $k$ integers is called a permutation if it contains all integers from $1$ to $k$ exactly once.

Another small reminder: a sequence $s$ is lexicographically smaller than another sequence $t$, if either $s$ is a prefix of $t$, or for the first $i$ such that $s_i \ne t_i$, $s_i < t_i$ holds (in the first position that these sequences are different, $s$ has smaller number than $t$).


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 1000$) — the number of test cases.

The first and only line of each test case contains two integers $n$ and $k$ ($k \le n < 2k$; $1 \le k \le 10^5$) — the length of the sequence $a$ and its maximum.

It's guaranteed that the total sum of $k$ over test cases doesn't exceed $10^5$.


-----Output-----

For each test case, print $k$ integers — the permutation $p$ which maximizes $b$ lexicographically without increasing the total number of inversions.

It can be proven that $p$ exists and is unique.


-----Examples-----

Input
4
1 1
2 2
3 2
4 3
Output
1 
1 2 
2 1 
1 3 2


-----Note-----

In the first test case, the sequence $a = [1]$, there is only one permutation $p = [1]$.

In the second test case, the sequence $a = [1, 2]$. There is no inversion in $a$, so there is only one permutation $p = [1, 2]$ which doesn't increase the number of inversions.

In the third test case, $a = [1, 2, 1]$ and has $1$ inversion. If we use $p = [2, 1]$, then $b = [p[a[1]], p[a[2]], p[a[3]]] = [2, 1, 2]$ and also has $1$ inversion.

In the fourth test case, $a = [1, 2, 3, 2]$, and since $p = [1, 3, 2]$ then $b = [1, 3, 2, 3]$. Both $a$ and $b$ have $1$ inversion and $b$ is the lexicographically maximum.

Difficulty: MEDIUM
Tags: Mathematics

Constructive algorithms

Starter code:

Solutions:
import sys
import math
inf = float('inf')

def lcm(a, b):
	return int(a / math.gcd(a, b) * b)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	perm = [0] * k
	diff = n - k + 1
	if diff == 0:
		ans = [i for i in range(1, k + 1)]
		print(*ans)
	else:
		z = k
		for i in range(k - diff, k):
			perm[i] = z
			z -= 1
		for i in range(k - diff):
			perm[i] = i + 1
		print(*perm)


import sys
input = lambda : sys.stdin.readline().strip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input().strip()
for _ in range(ii()):
	(n, k) = mi()
	a = [x + 1 for x in range(k)] + [x for x in range(k - 1, k - (n - k) - 1, -1)]
	p = [x + 1 for x in range(k)]
	count = n - k + 1
	p = p[:k - count] + list(reversed(p[k - count:]))
	print(*p)


import sys
T = int(input())
for t in range(T):
	row = list((int(x) for x in input().split()))
	N = row[0]
	K = row[1]
	P = list((str(x) for x in range(1, K + 1)))
	v1 = 2 * K - N
	P1 = P[:v1 - 1]
	P2 = P[v1 - 1:]
	P2.reverse()
	P1 += P2
	print(' '.join(P1))


cases = int(input())
for z in range(cases):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if n == k:
		for i in range(1, n + 1):
			print(i, end=' ')
		print('')
	else:
		num = 2 * k - n
		for i in range(1, num):
			print(i, end=' ')
		temp = k
		for i in range(num, k + 1):
			print(temp, end=' ')
			temp -= 1
		print('')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == 1 or n == 2 or n == k:
		print(*[i for i in range(1, n + 1)])
	else:
		a = [i + 1 for i in range(n - 2 * (n - k) - 1, k)]
		a.reverse()
		print(*[i + 1 for i in range(n - 2 * (n - k) - 1)], *a)


def factorial(n):
	fact = 1
	for i in range(2, n + 1):
		fact = fact * i
	return fact

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

def lcm(a, b):
	return a / gcd(a, b) * b
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	d = 2 * k - n - 1
	for i in range(1, d + 1):
		print(i, end=' ')
	for i in range(k, d, -1):
		print(i, end=' ')
	print()
	t -= 1


def solve():
	(n, k) = map(int, input().split())
	x = k - (n - k) - 1
	for i in range(1, x + 1):
		print(i, end=' ')
	for i in range(k, x + 1 - 1, -1):
		print(i, end=' ')
	print()
for _ in range(int(input())):
	solve()


T = int(input())
r = 1
while r <= T:
	(n, k) = map(int, input().split())
	inversion = (n - k) * (n - k + 1) // 2
	ans = [i + 1 for i in range(k)]
	part = 2 * k - n - 1
	ans[part:] = ans[part:][::-1]
	print(' '.join(map(str, ans)))
	r += 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(values, inversions) = ([], 0)
	for i in range(1, 2 * k - n):
		values.append(i)
	for i in range(k, 2 * k - n - 1, -1):
		values.append(i)
	print(*values)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	p = [0] * k
	i = 0
	count = 1
	while i < 2 * k - n - 1:
		p[i] = count
		i += 1
		count += 1
	i = k - 1
	while i >= 2 * k - n - 1:
		p[i] = count
		i -= 1
		count += 1
	print(' '.join([str(x) for x in p]))


import sys
MOD = 1000000007
import math

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

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

def get_line():
	return sys.stdin.readline().strip()

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

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

def solve():
	(n, k) = get_ints()
	diff = n - k
	if diff == 0:
		return ' '.join([str(i) for i in range(1, k + 1)])
	else:
		res1 = ' '.join([str(i) for i in range(1, k - diff)])
		res2 = ' '.join([str(i) for i in range(k, k - diff - 1, -1)])
		if res1 and res2:
			return res1 + ' ' + res2
		elif res1:
			return res1
		else:
			return res2
t = int(input())
while t:
	write_line(solve())
	t -= 1


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(N, K) = map(int, readline().split())
	L = list(range(1, 2 * K - N)) + list(range(K, 2 * K - N - 1, -1))
	Ans[qu] = ' '.join(map(str, L))
print('\n'.join(Ans))


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	val = k
	ans = [i + 1 for i in range(k)]
	for i in range(k - (n - k) - 1, k):
		ans[i] = val
		val -= 1
	print(*ans)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	p = [j + 1 for j in range(k)]
	rev_start = k - (n - k) - 1
	rev_end = k
	p[rev_start:rev_end] = reversed(p[rev_start:rev_end])
	print(*p)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(*[i for i in range(1, n + 1)])
	else:
		for i in range(1, 2 * k - n):
			print(i, end=' ')
		j = k
		while j >= 2 * k - n:
			print(j, end=' ')
			j -= 1
		print()


n = int(input())
for i in range(0, n):
	o = input().rstrip().split(' ')
	N = int(o[0])
	K = int(o[1])
	if N == K:
		for j in range(1, K + 1):
			print(j, end=' ')
		print()
	else:
		T = K - (N - K)
		H = K - T
		L = [0] * K
		for j in range(len(L) - 1, -1, -1):
			if H > 0:
				H -= 1
			else:
				L[j] = K
				G = j
				break
		E = 1
		for j in range(0, G):
			L[j] = E
			E += 1
		E = K - 1
		for j in range(G + 1, len(L)):
			L[j] = E
			E -= 1
		print(*L)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	l = list(range(1, k - (n - k)))
	l += list(range(k, k - (n - k) - 1, -1))
	print(*l)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	p = list(range(1, k - (n - k)))
	p += list(range(k, k - (n - k) - 1, -1))
	print(*p)


import sys
for line in list(sys.stdin)[1:]:
	inp = line.rstrip().split(' ')
	n = int(inp[0])
	k = int(inp[1])
	x = 2 * k - n - 1
	s = ''
	for i in range(1, x + 1):
		s += str(i) + ' '
	for i in range(k, x, -1):
		s += str(i) + ' '
	s = s[:-1]
	print(s)


case = int(input())
for i in range(case):
	(n, k) = map(int, input().strip().split())
	rem = n - k
	ara = [i for i in range(1, k - (rem + 1) + 1)]
	num = k
	for i in range(rem + 1):
		ara.append(num)
		num -= 1
	print(*ara)


for _ in range(int(input())):
	(n, k) = [int(t) for t in input().split()]
	t = n - k + 1
	ans = list(range(1, k + 1))
	ans[-t:] = reversed(ans[-t:])
	print(*ans)


import sys
from collections import Counter, deque
from functools import lru_cache
import heapq as hp
sys.setrecursionlimit(500005)
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
ns = lambda : stdin.readline().strip()
t = ni()

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

def lcm(a, b):
	return a // gcd(a, b) * b
while t:
	(n, k) = na()
	arr = list(range(1, n + 1))
	tmp = k - (n - k)
	for i in range(1, tmp):
		print(i, end=' ')
	for i in range(tmp, k + 1):
		print(k + tmp - i, end=' ')
	print()
	t -= 1


t = int(input())
for i in range(t):
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[-1])
	s = ''
	for j in range(1, 2 * k - n):
		s += str(j) + ' '
	for j in range(k, 2 * k - n - 1, -1):
		s += str(j) + ' '
	print(s[:-1])


ans = []

def solve():
	(n, k) = map(int, input().split())
	a = [0] * k
	j = 0
	for i in range(k):
		if i + 1 < 2 * k - n:
			a[i] = i + 1
		else:
			a[i] = k - j
			j += 1
	ans.append(' '.join((str(x) for x in a)))
	return
t = int(input())
while t > 0:
	solve()
	t -= 1
for x in ans:
	print(x)


import sys
input = sys.stdin.readline
getint = lambda : int(input())
getints = lambda : [int(a) for a in input().split()]

def solve():
	(n, k) = getints()
	slope_size = n - k + 1
	former_size = k - slope_size
	pre = [i + 1 for i in range(former_size)]
	after = [i for i in range(k, former_size, -1)]
	print(' '.join([str(i) for i in pre + after]))
t = getint()
for i in range(t):
	solve()


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7
for _ in range(II()):
	(n, k) = MI()
	ans = list(range(1, k + 1))
	i = 2 * k - n - 1
	ans = ans[:i] + ans[i:][::-1]
	print(*ans)


from itertools import combinations as P
t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = []
	j = 0
	for i in range(n):
		if j < k:
			j += 1
		else:
			break
		a.append(j)
	for i in range(n - k):
		j -= 1
		a.append(j)
	p = []
	i = n - 1
	while len(p) < k:
		if a[i] not in p:
			p.append(a[i])
		i -= 1
	print(*p[::-1])
	t -= 1


import sys
input = sys.stdin.buffer.readline
t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	diff = n - k
	p = [i + 1 for i in range(k)]
	p = p[0:k - diff - 1] + p[k - diff - 1:][::-1]
	print(*p)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	p = list(range(1, k + 1))
	p[k - 1 - (n - k):] = p[k - 1 - (n - k):][::-1]
	print(' '.join((str(x) for x in p)))


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)

def number_to_list(a):
	b = []
	while a >= 1:
		c = a % 10
		a = int(a / 10)
		b.append(c)
	return list(reversed(b))

def str_list_to_int_list(a):
	a = list(map(int, a))
	return a

def make_1d_array(n, inti=0):
	a = [inti for _ in range(n)]
	return a

def make_2d_array(n, m, inti=0):
	a = [[inti for _ in range(m)] for _ in range(n)]
	return a

def make_3d_array(n, m, k, inti=0):
	a = [[[inti for _ in range(k)] for _ in range(m)] for _ in range(n)]
	return a

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
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, k) = I()
	b = [i for i in range(1, k + 1)]
	if n == k:
		print(*b)
	else:
		d = b[:k - (n - k + 1)] + list(reversed(b[k - (n - k + 1):]))
		print(*d)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	for i in range(1, 2 * k - n):
		print(i, end=' ')
	for i in range(k, 2 * k - n - 1, -1):
		print(i, end=' ')
	print()


import sys
import math as mt
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, k) = I()
	temp = 2 * k - 1 - n
	ans = list(range(1, k + 1))
	ans[temp:] = reversed(ans[temp:])
	print(*ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	t = n - k
	p = [i for i in range(1, k + 1)]
	g = p[k - t - 1:]
	p = p[:k - t - 1] + g[::-1]
	print(*p)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = n - k
	l = k - temp
	ans = [i + 1 for i in range(k - temp - 1)]
	for i in range(n - k + 1):
		ans.append(k - i)
	print(' '.join(map(str, ans)))


from collections import defaultdict, deque
import sys
import bisect
import math
input = sys.stdin.readline
mod = 1000000007
t = int(input())
for ii in range(t):
	(n, k) = map(int, input().split())
	gap = n - k
	inver = 1
	p = [int(i) for i in range(1, k + 1)]
	gap = k - gap
	copy = p[gap - 1:]
	copy.reverse()
	p = p[:gap - 1]
	p += copy
	print(*p)


import math
import heapq

def S():
	return input()

def M():
	return map(int, input().split())

def I():
	return int(S())

def L():
	return list(M())
for _ in range(I()):
	(n, k) = M()
	if n - k + 1 >= k:
		for i in range(k, 0, -1):
			print(i, end=' ')
	else:
		for i in range(1, k - (n - k + 1) + 1):
			print(i, end=' ')
		for i in range(k, k - n + k - 1, -1):
			print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	i = n - k
	ans = list(range(1, k + 1))
	if i == 0:
		print(*ans)
	else:
		ans = ans[:-(i + 1)] + list(range(k, k - i - 1, -1))
		print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	inv = (n - k) * (n - k + 1) - (n - k)
	i1 = 1
	k1 = n - k
	i2 = k
	for i in range(k):
		if k - i <= k1 + 1:
			print(i2, end=' ')
			i2 -= 1
		else:
			print(i1, end=' ')
			i1 += 1
	print()


for _ in range(int(input())):
	(n, k) = [int(a) for a in input().split()]
	mid = k - 1
	diff = n - k
	a = list(range(1, k + 1)) + list(range(mid, mid + diff, -1))
	a[mid - diff:mid + diff] = reversed(a[mid - diff:mid + diff])
	print(*a[:k])


import sys
from sys import stdin, stdout
from math import ceil, floor, sqrt, log, log2, log10
from collections import Counter
int_max = float('inf')
int_min = -float('inf')
ANS = []
input = stdin.readline

def solve():
	pass
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(range(1, k + 1))
	diff = n - k
	p = []
	for i in range(k - diff - 1):
		p.append(a[i])
	for i in range(k - 1, k - diff - 2, -1):
		p.append(a[i])
	print(*p)


T = int(input())
for t in range(T):
	(n, k) = tuple([int(x) for x in input().split()])
	last_num = k - (n - k)
	result = []
	start_reverse = False
	cur_num = 1
	for i in range(1, k + 1):
		if i < last_num:
			result.append(cur_num)
			cur_num += 1
		else:
			if start_reverse == False:
				start_reverse = True
				cur_num = k
			result.append(cur_num)
			cur_num -= 1
	print(' '.join([str(x) for x in result]))


t = int(input())
for i in range(t):
	nk = [int(x) for x in input().split()]
	n = nk[0]
	k = nk[1]
	for j in range(k + k - (n + 1)):
		print(j + 1, end=' ')
	for j in range(n + 1 - k):
		print(k - j, end=' ')
	print('')


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(*[i + 1 for i in range(2 * k - n - 1)] + [k - i for i in range(n - k + 1)])


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = [i for i in range(1, 2 * k - n)]
	for i in range(n - k + 1):
		l.append(k - i)
	print(*l)


task_number = int(input())
for _ in range(task_number):
	(n, k) = map(int, input().split())
	result = list(range(1, k + 1))
	z = n - k
	result[-z - 1:] = reversed(result[-z - 1:])
	print(' '.join([str(x) for x in result]))


test_num = int(input())
tests = list()
for i in range(test_num):
	tests.append(map(int, input().split()))
for (n, k) in tests:
	for i in range(1, 2 * k - n):
		print(i, end=' ')
	for i in range(k, 2 * k - n - 1, -1):
		print(i, end=' ')
	print()


for z in range(int(input())):
	(n, k) = map(int, input().split())
	num = (n - k) ** 2
	num2 = 2 * k - 1 - n
	ans = []
	for i in range(num2):
		ans.append(i + 1)
	for i in range(k, num2, -1):
		ans.append(i)
	print(*ans)


t = int(input())
for i in range(t):
	inp = input()
	(n, k) = [int(it) for it in inp.split(' ')]
	p = []
	p1_len = 2 * k - n
	l = list(range(1, p1_len))
	for j in range(n - k + 1):
		l.append(k - j)
	print(*l)


t = int(input())
import math
while t > 0:
	t -= 1
	(n, d) = input().split()
	(n, k) = (int(n), int(d))
	dif = n - k
	i = 0
	while i < k - dif - 1:
		print(i + 1, end=' ')
		i += 1
	j = k
	while j > i:
		print(j, end=' ')
		j -= 1
	print()


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = n - k
	for i in range(1, k + 1):
		if i < k - x:
			print(i, end=' ')
		else:
			print(k - x + k - i, end=' ')
	print()


def main():
	t = int(input())
	allAns = []
	for _ in range(t):
		(n, k) = readIntArr()
		ans = list(range(1, k + 1))
		start = k - (n - k) - 1
		curr = k
		for i in range(start, k):
			ans[i] = curr
			curr -= 1
		allAns.append(ans)
	multiLineArrayOfArraysPrint(allAns)
	return
import sys
input = sys.stdin.buffer.readline

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()]
inf = float('inf')
MOD = 10 ** 9 + 7
main()


def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		m = k * 2 - n
		print(*range(1, m), *range(k, m - 1, -1))
main()


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, K):
	return list(range(1, 2 * K - N)) + list(range(K, 2 * K - N - 1, -1))

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


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	r = [y + 1 for y in range(c)]
	d = []
	h = 1
	t = 0
	for x in range(b):
		if t == 0:
			d.append(h)
			h += 1
			if h > c:
				h = c - 1
				t = -1
		else:
			d.append(h)
			h -= 1
			if h <= 0:
				h = 1
				t = 0
	n = {}
	for y in d:
		if n.get(y) == None:
			n[y] = 1
		else:
			n[y] += 1
	p = c
	for y in n:
		if n[y] > 1:
			p = y - 1
			break
	z = r[p:]
	z.sort(reverse=True)
	ss = r[:p] + z
	print(*ss)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, groupby, zip_longest
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
tup = lambda : map(int, sys.stdin.buffer.readline().split())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
stpr = lambda x: sys.stdout.write(f'{x}' + '\n')
star = lambda x: print(' '.join(map(str, x)))
localsys = 0
start_time = time.time()
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(I()):
	(n, k) = tup()
	print(*[*range(1, 2 * k - n)] + [*range(k, 2 * k - n - 1, -1)])
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


from sys import stdin, stdout
from math import ceil
for test in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().strip().split())
	a = []
	for i in range(k):
		a.append(i + 1)
	for i in range(k - 1, k - (n - k) - 1, -1):
		a.append(i)
	inv = n - k
	ans = []
	if inv == -100:
		print(*a[:k])
	else:
		for i in range(k - inv - 1):
			ans.append(i + 1)
		for i in range(k, k - inv - 1, -1):
			ans.append(i)
		print(*ans)


def solve():
	(n, k) = map(int, input().split())
	pos = 2 * k - n - 1
	a = [0] * k
	p = k
	for i in range(pos, pos + n - k):
		a[i] = p
		p -= 1
	p = 1
	for i in range(k):
		if a[i] == 0:
			a[i] = p
			p += 1
	print(*a)

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


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split(' ')]
	a = [i for i in range(1, 2 * k - n)]
	b = [i for i in range(2 * k - n, k + 1)]
	b.reverse()
	a.extend(b)
	print(*a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k1 = 2 * k - n - 1
	a = [i for i in range(1, k + 1)]
	b = []
	for i in range(k):
		if i < k1:
			b.append(a[i])
		else:
			b.append(a[k1 - i - 1])
	print(*b)


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	aa = k - (n - k)
	print(*list(range(1, aa)) + list(range(k, aa - 1, -1)))


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	ans = []
	marked = [False for i in range(k + 1)]
	t = k - 1
	while t >= k - (n - k):
		ans.append(t)
		marked[t] = True
		t -= 1
	temp = []
	for i in range(1, k + 1):
		if not marked[i]:
			temp.append(i)
	for i in ans:
		temp.append(i)
	print(*temp)


for i1 in range(int(input())):
	(n, k) = map(int, input().split())
	x = 2 * k - n
	l = []
	for i in range(1, x):
		l.append(i)
	y = k
	for i in range(n - k + 1):
		l.append(y)
		y = y - 1
	for i in l:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [0] * k
	inverted = n - k
	l = k
	for i in range(k):
		if k - inverted > i + 1:
			arr[i] = i + 1
		else:
			arr[i] = l
			l -= 1
	print(*arr, sep=' ')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n == k:
		ans = [i + 1 for i in range(k)]
		print(*ans)
	else:
		t = 2 * k - n - 1
		ans = [i + 1 for i in range(t)]
		temp = []
		for i in range(t, k):
			temp.append(i + 1)
		temp.sort(reverse=True)
		ans += temp
		print(*ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k - (n - k) - 1
	for i in list(range(1, x + 1)) + list(range(k, x, -1)):
		print(i, end=' ')
	print()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = 2 * k - n
	for i in range(1, t):
		print(i, end=' ')
	for i in range(k, t - 1, -1):
		print(i, end=' ')
	print()


import sys
import os
import math
import copy
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations, accumulate

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

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

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

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

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

def Hash():
	return dict()

def Mod():
	return 1000000007

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def watch(x):
	return print(x)

def common(l1, l2):
	return set(l1).intersection(l2)

def Most_frequent(list):
	return max(set(list), key=list.count)

def solution():
	for _ in range(Int()):
		(n, k) = Mint()
		a = []
		for i in range(1, k + 1):
			a.append(i)
		x = k - 1
		for i in range(k + 1, n + 1):
			a.append(x)
			x -= 1
		b = Counter(a)
		ans = []
		for i in range(n):
			if b[a[i]] == 2:
				b[a[i]] = 1
			else:
				ans.append(a[i])
		print(*ans)
solution()


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 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 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 = 9
	n = random.randint(1, N)
	A = [random.randint(1, n) for i in range(m)]
	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)]

class Bit:

	def __init__(self, n):
		self.size = n
		self.m = len(bin(self.size)) - 2
		self.arr = [0] * (2 ** self.m + 1)

	def __str__(self):
		return str(self.arr)

	def add(self, i, x):
		k = 0
		while i <= self.size:
			k += 1
			self.arr[i] += x
			i += i & -i
		return

	def sum(self, i):
		rt = 0
		while i > 0:
			rt += self.arr[i]
			i -= i & -i
		return rt

	def l_bound(self, w):
		if w <= 0:
			return 0
		x = 0
		k = 2 ** self.m
		while k > 0:
			if x + k < self.size and self.arr[x + k] < w:
				w -= self.arr[x + k]
				x += k
			k //= 2
		return x + 1

	def u_bound(self, w):
		if w <= 0:
			return 0
		x = 0
		k = 2 ** self.m
		while k > 0:
			if x + k < self.size and self.arr[x + k] <= w:
				w -= self.arr[x + k]
				x += k
			k //= 2
		return x + 1

class Bit0(Bit):

	def add(self, j, x):
		super().add(j + 1, x)

	def l_bound(self, w):
		return max(super().l_bound(w) - 1, 0)

	def u_bound(self, w):
		return max(super().u_bound(w) - 1, 0)

class Multiset(Bit0):

	def __init__(self, max_v):
		super().__init__(max_v)

	def insert(self, x):
		super().add(x, 1)

	def find(self, x):
		return super().l_bound(super().sum(x))

	def __str__(self):
		return str(self.arr)

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
show_flg = False
show_flg = True

def inv(b):
	n = len(b)
	rt = 0
	for i in range(n):
		for j in range(i + 1, n):
			if b[i] > b[j]:
				rt += 1
	return rt

def naive(n, k):
	a = list(range(1, k + 1)) + list(range(k - (n - k), k)[::-1])
	a = list(range(k)) + list(range(k - (n - k) - 1, k - 1)[::-1])
	iv = inv(a)
	show('naive', '(n,k)=', (n, k), a, iv)
	rt = tuple(range(k))
	for p in permutations(range(k)):
		b = [p[i] for i in a]
		if inv(b) <= iv:
			rt = max(rt, p)
	show(rt)
	ans = solve(n, k)
	print(*ans)

def solve(n, k):
	t = n - k
	return list(range(1, k - t)) + list(range(k - t, k + 1))[::-1]
for _ in range(I()):
	(n, k) = LI()
	ans = solve(n, k)
	print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	a = []
	ans = []
	d = {}
	for i in range(k):
		a.append(i + 1)
	for i in range(n - k):
		a.append(k - i - 1)
	for i in range(n - 1, -1, -1):
		if a[i] not in d:
			ans.append(a[i])
			d[a[i]] = a[i]
	ans.reverse()
	print(*ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	p = []
	for j in range(2 * k - n - 1):
		p.append(j + 1)
	for j in range(n - k + 1):
		p.append(k - j)
	print(*p)


def calc(n, k):
	arr = []
	cur = n - k
	while cur > 0:
		arr.append(k - cur)
		cur -= 1
	arr = [x for x in range(1, k + 1)] + arr[::-1]
	return arr
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lis = calc(n, k)
	idx = lis.index(k)
	vis = set()
	idx += 1
	tmpi = idx
	while idx < n:
		vis.add(lis[idx])
		idx += 1
	i = 0
	while i < k:
		if i + 1 not in vis:
			print(i + 1, end=' ')
		i += 1
	while tmpi < n:
		print(lis[tmpi], end=' ')
		tmpi += 1
	print()


testcases = int(input())
for i in range(testcases):
	(n, m) = map(int, input().split())
	s1 = n - 1 - 2 * (n - m)
	for i in range(1, s1 + 1):
		print(i, end=' ')
	for i in range(m, s1, -1):
		print(i, end=' ')
	print()


try:
	for i in range(int(input())):
		(n, k) = map(int, input().split())
		val = k - (n - k)
		s = list(range(1, k + 1))
		s1 = s[0:val - 1]
		s2 = list(reversed(s[val - 1:k]))
		s = s1 + s2
		print(*s)
except:
	pass


T = int(input())
while T > 0:
	T = T - 1
	(n, k) = map(int, input().split())
	for i in range(1, 2 * k - n):
		print(i, end=' ')
	for i in range(k, 2 * k - n - 1, -1):
		print(i, end=' ')
	print()


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


import sys, collections, math, itertools, random, bisect
INF = sys.maxsize

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

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

def input():
	return sys.stdin.readline().strip()
mod = int(1000000000.0 + 7)
for _ in range(int(input())):
	(n, k) = get_ints()
	arr = [i + 1 for i in range(k)]
	temp = k - 1
	for i in range(n - k):
		arr.append(temp)
		temp -= 1
	vis = [0] * int(100000.0 + 7)
	ans = []
	for i in range(n - 1, -1, -1):
		if vis[arr[i]] == 1:
			continue
		else:
			ans.append(arr[i])
			vis[arr[i]] = 1
	ans.reverse()
	print(*ans)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	m = n - k
	for i in range(1, k - m):
		print(i, end=' ')
	for i in range(k, k - m - 1, -1):
		print(i, end=' ')
	print()
	t -= 1


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
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 TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=2 ** 51, 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)

class SegmentTree:

	def __init__(self, data, default=-2 ** 51, 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 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

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	(n, k) = map(int, input().split())
	ans = [0] * k
	t = k
	for i in range(k - (n - k) - 1, k):
		ans[i] = t
		t -= 1
	t = 1
	for i in range(0, k - (n - k) - 1):
		ans[i] = t
		t += 1
	print(*ans)


for z in range(int(input())):
	(n, k) = map(int, input().split())
	dif = n - k + 1
	l = list(range(1, k - dif + 1))
	for i in range(dif):
		l.append(k - i)
	print(*l)


import sys
input = sys.stdin.readline
for tc in range(int(input())):
	(n, k) = map(int, input().split())
	last = k * 2 - n
	ans = []
	for i in range(1, last):
		ans.append(i)
	for i in range(k, last - 1, -1):
		ans.append(i)
	for i in range(k):
		print(ans[i], end=' ')
	print()


t = int(input().strip())
for _ in range(t):
	(n, k) = map(int, input().strip().split())
	l = n - k
	T = list(range(1, k - l)) + list(range(k, k - l - 1, -1))
	print(' '.join(map(str, T)))


for tc in range(int(input())):
	(n, k) = map(int, input().split())
	m = 2 * k - n - 1
	p = [i for i in range(1, m + 1)] + [i for i in range(k, m, -1)]
	print(' '.join([str(i) for i in p]))


import math

def input_int():
	return int(input())

def input_list():
	return input().split(' ')

def input_list_int():
	return list(map(int, input_list()))

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

def solve():
	(n, k) = input_list_int()
	b = k * 2 - 1
	ans = []
	for i in range(b - n):
		ans.append(str(i + 1))
	v = k
	for i in range(k - len(ans)):
		ans.append(str(v))
		v -= 1
	print(' '.join(ans))
query_count = input_int()
while query_count:
	query_count -= 1
	solve()


import sys
import bisect
import math
input = lambda : sys.stdin.readline().strip()
q = int(input())
while q:
	q -= 1
	(n, k) = map(int, input().split())
	for i in range(1, k - (n - k)):
		print(i, end=' ')
	for i in range(k, k - (n - k) - 1, -1):
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline
import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = list(range(1, 2 * k - n)) + list(range(k, 2 * k - n - 1, -1))
	print(*ans)


import sys

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

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

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

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

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		(n, k) = get_ints()
		ans = list(range(1, 2 * k - n))
		ans += list(range(k, 2 * k - n - 1, -1))
		get_print(' '.join(map(str, ans)))
solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	num = []
	la = 2 * k - n
	i = 1
	while i < la:
		num.append(i)
		i += 1
	while k >= la:
		num.append(k)
		k -= 1
	print(*num)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	l = 2 * k - n - 1
	z = []
	for i in range(1, l + 1):
		z.append(i)
	for j in range(k, l, -1):
		z.append(j)
	print(*z)


import sys
import math
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	l = []
	k1 = 0
	for i in range(1, 2 * k - n):
		l.append(i)
		k1 = i
	for i in range(k, k1, -1):
		l.append(i)
	print(*l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = [x for x in range(1, k + 1)]
	num = k - (n - k)
	print(*p[:num - 1], *p[num - 1:][::-1])


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	ans = []
	for i in range(2 * k - n - 1):
		ans.append(i + 1)
	for i in range(k, 2 * k - n - 1, -1):
		ans.append(i)
	print(*ans)


t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	x = n - k
	for i in range(1, k - x):
		print(i, end=' ')
	for i in range(k, k - x - 1, -1):
		print(i, end=' ')
	print()
	t -= 1


for test in range(int(input())):
	(n, k) = map(int, input().split())
	print(*[i for i in range(1, k - (n - k))] + [i for i in range(k, k - (n - k) - 1, -1)])


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	n = b - (a - b)
	for i in range(1, n):
		print(i, end=' ')
	for i in range(b, n - 1, -1):
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	w = list(range(1, k - (n - k)))
	w2 = list(range(k - (n - k), k + 1))
	w2.reverse()
	w.extend(w2)
	print(*w)


import sys

def noMoreInversions(n, k):
	p = [str(i) for i in range(1, k + 1)]
	for i in range(2 * k - n - 1, (3 * k - n - 1) // 2):
		(p[i], p[3 * k - n - 2 - i]) = (p[3 * k - n - 2 - i], p[i])
	return ' '.join(p)

def main():
	for t in range(int(input())):
		(n, k) = map(int, input().split())
		print(noMoreInversions(n, k))
main()


import math

def solve():
	(n, k) = map(int, input().split())
	a = [i for i in range(1, 2 * k - n)]
	b = [i for i in range(2 * k - n, k + 1)]
	b = list(reversed(b))
	print(*a + b)
t = 1
t = int(input())
for _ in range(t):
	solve()


import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict, deque, Counter, OrderedDict
import threading
from heapq import *

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		D = [i for i in range(1, k + 1)] + [i for i in range(k - 1, 2 * k - n - 1, -1)]
		p = [i for i in range(1, k + 1)][::-1]
		p = p[:n - k + 1][::-1] + p[n - k + 1:]
		print(*p[::-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()


import sys, math
sys.setrecursionlimit(10 ** 6)
fastinput = sys.stdin.readline
fastout = sys.stdout.write
t = int(fastinput())
while t:
	t -= 1
	(n, k) = map(int, fastinput().split())
	a = [i for i in range(1, k + 1)]
	x = n - k + 1
	j = k - x
	temp = k
	for i in range(x):
		a[j + i] = temp
		temp -= 1
	print(*a)


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().strip().split())
	inv = n - k
	ans = [i for i in range(1, k - inv)] + [i for i in range(k, k - inv - 1, -1)]
	print(*ans)


import sys
from collections import deque
T = int(input())
for t in range(T):
	(n, k) = map(int, sys.stdin.readline().strip().split())
	for i in range(1, k - n + k):
		sys.stdout.write(str(i) + ' ')
	for i in range(k, k - n + k - 1, -1):
		sys.stdout.write(str(i) + ' ')
	sys.stdout.write('\n')


import sys
import heapq
from collections import deque

def find(parent, i):
	if parent[i] != i:
		parent[i] = find(parent, parent[i])
	return parent[i]

def union(parent, rank, xx, yy):
	x = find(parent, xx)
	y = find(parent, yy)
	if rank[x] > rank[y]:
		parent[y] = x
	elif rank[y] > rank[x]:
		parent[x] = y
	else:
		parent[y] = x
		rank[x] += 1
ans = 0
n = int(sys.stdin.readline().strip())
for j in range(n):
	AB = sys.stdin.readline().strip().split()
	n = int(AB[0])
	m = int(AB[1])
	l = [str(i + 1) for i in range(m)]
	if 2 * m - 1 - n == 0:
		l.reverse()
		print(' '.join(l))
	else:
		ll = l[2 * m - 1 - n:]
		ll.reverse()
		k = l[:2 * m - 1 - n] + ll
		print(' '.join(k))


rn = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rns = lambda : map(int, input().split())
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
for _ in range(rn()):
	(n, k) = rns()
	pre = n - k
	ans = []
	for i in range(1, k - pre):
		ans.append(i)
	for i in range(k, k - pre - 1, -1):
		ans.append(i)
	print(*ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [i for i in range(1, k + 1)]
	num = k - 1
	while len(a) < n:
		a.append(num)
		num -= 1
	ans = a[k - 1:]
	m = k - len(ans)
	ans = a[:m] + ans
	print(*ans)


t = int(input())
for j in range(0, t):
	l1 = [int(x) for x in input().split()]
	n = l1[0]
	k = l1[1]
	p = []
	for i in range(1, 2 * k - n):
		p.append(i)
	for i in range(k, 2 * k - n - 1, -1):
		p.append(i)
	for i in p:
		print(i, end=' ')
	print()


import sys, getpass
import math, random
import functools, itertools, collections, heapq, bisect
from collections import Counter, defaultdict, deque
input = sys.stdin.readline
M9 = 10 ** 9 + 7
MAXINT = sys.maxsize
OFFLINE_TEST = getpass.getuser() == 'hkmac'

def log(*args):
	if OFFLINE_TEST:
		print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)

def solve(*args):
	if OFFLINE_TEST:
		log('----- solving ------')
		log(*args)
		log('----- ------- ------')
	return solve_(*args)

def read_matrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]

def read_strings(rows):
	return [input().strip() for _ in range(rows)]

def solve_(a, b):
	extra = a - b
	res = list(range(1, b + 1))
	if extra == 0:
		return res
	res[-extra - 1:] = res[-extra - 1:][::-1]
	return res
for case_num in range(int(input())):
	(a, b) = list(map(int, input().split()))
	res = solve(a, b)
	print(*res)


for _ in [*open(0)][1:]:
	(n, k) = map(int, _.split())
	r = 2 * k - 2 - n
	print(*[i for i in range(1, r + 2)] + [i for i in range(k, r + 1, -1)])


import sys
input = sys.stdin.readline

def solve():
	(n, k) = map(int, input().split())
	if k == 1 or n == 1:
		return [1]
	ans = [i for i in range(1, k + 1)]
	if n == k:
		return ans
	(f, b) = (k - (n - k) - 1, k - 1)
	while f < b:
		(ans[f], ans[b]) = (ans[b], ans[f])
		f += 1
		b -= 1
	return ans
for _ in range(int(input())):
	print(*solve())


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	r = 2 * k - n
	p = [str(i) for i in range(1, r)]
	for i in range(0, k + 1 - r):
		p.append(str(k - i))
	print(' '.join(p))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	res = []
	cur = 1
	for i in range(1, 2 * k - n):
		res.append(str(cur))
		cur += 1
	cur = k
	for i in range(2 * k - n, k + 1):
		res.append(str(cur))
		cur -= 1
	print(' '.join(res))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt, log2
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

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

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

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

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

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

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

def testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	y %= p - 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	(n, k) = sep()
	for i in range(k - (n - k + 1)):
		print(i + 1, end=' ')
	curr = k
	chck = n - k + 1
	while curr and chck:
		print(curr, end=' ')
		curr -= 1
		chck -= 1
	print()
testcase(int(inp()))


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	b = []
	for i in range(1, 2 * k - n):
		b.append(i)
	for i in range(n - k + 1):
		b.append(k - i)
	print(*b)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	L = [int(x) for x in stdin.readline().split(' ')]
	(n, k) = (L[0], L[1])
	d = n - k + 1
	r = k - d
	res = []
	for i in range(r):
		res.append(i + 1)
	curr = k
	while len(res) < k:
		res.append(curr)
		curr -= 1
	print(' '.join([str(x) for x in res]))


try:
	for i in range(int(input())):
		(n, k) = map(int, input().split())
		j = k - (n - k)
		s = list(range(1, k + 1))
		l = s.index(j)
		m = len(s) - 1
		i = l
		while i < m:
			temp = s[i]
			s[i] = s[m]
			s[m] = temp
			m -= 1
			i += 1
		for i in s:
			print(i, end=' ')
		print()
except:
	pass


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	for j in range(1, 2 * k - n):
		print(j, end=' ')
	for j in range(2 * k - n, k + 1):
		print(3 * k - n - j, end=' ')
	print()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	g = []
	for j in range(2 * k - n):
		g.append(j + 1)
	if n - k == 0:
		print(' '.join(map(str, g)))
	else:
		h = []
		for j in range(k - 1 - n + k):
			h.append(j + 1)
		for j in range(k - (k - 1 - n + k)):
			h.append(k - j)
		print(' '.join(map(str, h)))


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
testcases = vary(1)
for _ in range(testcases):
	(n, k) = vary(2)
	num = [i for i in range(1, k + 1)]
	if n == k:
		print(*num)
	else:
		l = [i for i in range(1, 2 * k - n)]
		for i in range(n - k + 1):
			l.append(k - i)
		print(*l)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	e = 2 * k - n
	for x in range(1, e):
		print(x, end=' ')
	for x in range(k, e - 1, -1):
		print(x, end=' ')
	print()


import os, io, math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = []
	for i in range(1, 2 * k - n):
		ans.append(str(i))
	for j in range(n - k + 1):
		ans.append(str(k - j))
	print(' '.join(ans))


from sys import stdin
from math import gcd
input = lambda : stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	(n, k) = map(int, input().split())
	an = []
	for i in range(2 * k - n - 1):
		an.append(i + 1)
	for i in range(k, 2 * k - n - 1, -1):
		an.append(i)
	print(*an)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n <= k:
		ans = []
		for i in range(1, n + 1):
			print(i, end=' ')
	else:
		inv = n - k
		for i in range(1, k - inv):
			print(i, end=' ')
		for i in range(k, k - inv - 1, -1):
			print(i, end=' ')
	print()


t = int(input())
for q in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, k) = (L[0], L[1])
	L = []
	for i in range(1, k - (n - k)):
		L.append(i)
	m = k
	ch = ''
	while len(L) < k:
		L.append(m)
		m -= 1
	for i in L:
		ch += str(i) + ' '
	print(ch)


import sys
import os

def solve():
	(n, k) = list(map(int, input().split()))
	arr = []
	o = 0
	for i in range(n):
		o += -1 if i >= k else 1
		arr.append(str(o))
	p = []
	s = set()
	for i in range(n - 1, -1, -1):
		if arr[i] not in s:
			p.append(arr[i])
			s.add(arr[i])
	p.reverse()
	print(' '.join(p))
num = int(input())
for n in range(num):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	a = [i for i in range(1, k + 1)]
	print(*a[:-(n - k) - 1] + a[-1:-(n - k) - 2:-1])


for _ in range(int(input())):
	(n, k) = (int(x) for x in input().split())
	if n == k:
		a = [x for x in range(1, k + 1)]
		print(*a)
		continue
	a = [x for x in range(1, k + 1)]
	b = a[:2 * k - n - 1]
	c = a[2 * k - n - 1:]
	if len(c) > 0:
		c.reverse()
		b += c
	print(*b)


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = list(range(1, k + 1))
	b = list(range(2 * k - n, k))
	b.sort()
	x = n - k
	q = a[0:k - x - 1] + [a[-1]]
	r = a[k - x - 1:-1]
	r = r[::-1]
	print(*q + r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = [i for i in range(1, k + 1)]
	m = n - k + 1
	z = ans[-m:]
	tot = ans[:k - m]
	out = tot + z[::-1]
	print(*out)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	i = 1
	ind = []
	tmp = k
	while i <= k:
		if i >= k - (n - k):
			ind.append(tmp)
			tmp -= 1
		else:
			ind.append(i)
		i += 1
	print(*ind)


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split(' '))
	for i in range(1, 2 * k - n):
		print(i, end=' ')
	ct = k
	for i in range(n - k + 1):
		print(ct, end=' ')
		ct -= 1
	print('')


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().strip().split())
	a = [0 for i in range(k)]
	index = 0
	for i in range(1, 2 * k - n):
		a[index] = i
		index += 1
	for i in range(k, 2 * k - n - 1, -1):
		a[index] = i
		index += 1
	print(*a)


from sys import stdin
readline = stdin.readline

def read_ints():
	return map(int, readline().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(n, k) = read_ints()
	m = n - k
	a_part = range(1, k - m - 1 + 1)
	b_part = reversed(range(k - m, k + 1))
	result = list(a_part) + list(b_part)
	print(*result)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def solution():
	(n, k) = map(int, input().split())
	l = []
	for i in range(1, 2 * k - n):
		l.append(i)
	for i in range(k, 2 * k - n - 1, -1):
		l.append(i)
	print(*l)
t = int(input())
for _ in range(t):
	solution()


from __future__ import print_function
from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	(n, k) = gil()
	if n == k:
		ans = [str(i) for i in range(1, n + 1)]
	else:
		inv = n - k
		s = k - inv
		ans = []
		for i in range(1, s):
			ans.append(str(i))
		for i in range(k, s - 1, -1):
			ans.append(str(i))
	print(' '.join(ans))


try:
	t = int(input())
	while t != 0:
		(n, k) = map(int, input().split())
		if n == k:
			arr = []
			for i in range(1, n + 1):
				arr.append(i)
			print(*arr)
		else:
			arr = []
			less = n - k
			for i in range(1, k + 1):
				arr.append(i)
			put = k
			for i in range(k - 1 - less, k):
				arr[i] = put
				put -= 1
			print(*arr)
		t -= 1
except EOFError:
	print(' ')


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	ans = ''
	print(' '.join([str(i) for i in range(1, 2 * k - n)] + [str(i) for i in range(k, 2 * k - n - 1, -1)]))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int():
	return int(stdin.readline().strip())

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

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

def solve():
	(n, k) = get_tuple()
	if n == k:
		ans = [i for i in range(1, n + 1)]
		print(*ans)
		return
	(s, p) = (k, k)
	ans = []
	while s <= n:
		ans.append(p)
		p -= 1
		s += 1
	ans = [i for i in range(1, p + 1)] + ans
	print(*ans)
testcases = True
if testcases:
	t = get_int()
	for _ in range(t):
		solve()
else:
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(*list(range(1, k - (n - k))) + list(range(k, k - (n - k) - 1, -1)))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = []
	for i in range(1, k + 1):
		a.append(i)
	c = 0
	x = k - 1
	while c < n - k:
		a.append(x)
		x -= 1
		c += 1
	(p, s) = ([], set())
	for i in range(n - 1, -1, -1):
		if a[i] not in s:
			p.append(a[i])
			s.add(a[i])
	for i in range(k - 1, -1, -1):
		print(p[i], end=' ')
	print('')


from sys import stdin, gettrace
if gettrace():

	def inputi():
		return input()
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, k) = map(int, input().split())
	last = 2 * k - n
	res = list(range(1, last)) + list(range(k, last - 1, -1))
	print(' '.join(map(str, res)))

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


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

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

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

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		for _ in range(inp()):
			(n, k) = invr()
			a = [i + 1 for i in range(k)]
			val = k - (n - k) - 1
			print(*a[:val] + list(reversed(a[val:])), sep=' ')
	except Exception as e:
		print(e)
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
from math import gcd
tt = int(input())
for i in range(tt):
	(n, k) = map(int, input().split())
	tmp = k * 2 - n
	for j in range(tmp - 1):
		stdout.write(str(j + 1) + ' ')
	for i in range(tmp - 1, k):
		stdout.write(str(k) + ' ')
		k -= 1
	stdout.write('\n')


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	res = []
	for i in range(1, 2 * k - n):
		res.append(i)
	for i in range(k, -1, -1):
		res.append(i)
	for i in range(k):
		print(res[i], end=' ')
	print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = [i for i in range(1, k + 1)]
	go = k - 1
	if n - k == 0:
		print(*list(range(1, n + 1)))
	else:
		for i in range(n - k):
			arr.append(go)
			go -= 1
		res = [i for i in range(1, k + 1)]
		j = k - 1
		go = arr[-1]
		while go < k + 1:
			res[j] = go
			j -= 1
			go += 1
		print(*res)


import sys
input = sys.stdin.readline

def solution(n, k):
	arr = []
	for i in range(1, k - (n - k)):
		arr.append(i)
	for i in range(k, k - (n - k) - 1, -1):
		arr.append(i)
	return arr
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(*solution(n, k))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = []
	arr1 = []
	for i in range(1, 2 * k - n):
		arr.append(i)
	c = k
	while c >= 2 * k - n:
		arr1.append(c)
		c -= 1
	arr = arr + arr1
	print(*arr)


t = int(input())
for T in range(t):
	(n, k) = [int(i) for i in input().split()]
	output = [0] * k
	for i in range(2 * k - n - 1):
		output[i] = i + 1
		maxi = i + 1
	q = k
	for i in range(2 * k - n - 1, k):
		output[i] = q
		q -= 1
	print(' '.join([str(i) for i in output]))


import math, random

def prime(size):
	prime = [True for i in range(size + 1)]
	i = 2
	while i * i <= size:
		if prime[i] == True:
			j = i * 2
			while j < size:
				prime[j] = False
				j += i
		i += 1
	prime[0] = False
	prime[1] = False
	return prime

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

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

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

def solve():
	(n, k) = arr()
	l = [x for x in range(1, k + 1)]
	l2 = l[k - (n - k) - 1:k + 1]
	l = l[:k - (n - k) - 1]
	l2.reverse()
	if l == []:
		print(*l2)
		return
	ans = l + l2
	print(*ans)
t = 1
t = int(input())
for i in range(t):
	ans = solve()
	if ans == None:
		continue
	print(ans)


import math
t = int(input())
while t > 0:
	(n, k) = [int(i) for i in input().split()]
	a = []
	for i in range(1, 2 * k - n):
		a.append(i)
	for i in range(k, 2 * k - n - 1, -1):
		a.append(i)
	print(*a)
	t -= 1


mod = 1000000007
inf = int(1e+18)

def solve():
	(n, k) = map(int, input().split())
	if n == k:
		print(' '.join(map(str, range(1, k + 1))))
		return
	a = list(range(1, k + 1))
	if n == k + 1:
		(a[-1], a[-2]) = (a[-2], a[-1])
	else:
		a = a[:k - (n - k) - 1] + a[k - (n - k) - 1:][::-1]
	print(*a)

def main():
	n = int(input())
	for i in range(n):
		solve()
main()


R = lambda : list(map(int, input().split()))
for _ in ' ' * int(input()):
	(n, k) = R()
	a = [i + 1 for i in range(k)]
	a = a[:2 * k - n - 1] + a[2 * k - n - 1:][::-1]
	print(*a)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations, combinations

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
sys.setrecursionlimit(100000)
INF = float('inf')
mod = 10 ** 9 + 7
for t in range(int(data())):
	(n, k) = mdata()
	outl(list(range(1, 2 * k - n)) + list(range(k, 2 * k - n - 1, -1)))