You are given two positive integers $N$ and $K$, where $K \le N$. Find a sequence $A_1, A_2, \ldots, A_N$ such that:
- for each valid $i$, $A_i$ is either $i$ or $-i$
- there are exactly $K$ values of $i$ such that $1 \le i \le N$ and $A_1 + A_2 + \ldots + A_i > 0$
If there are multiple solutions, you may print any one of them. It can be proved that at least one solution always exists.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first and only line of each test case contains two space-separated integers $N$ and $K$.

-----Output-----
For each test case, print a single line containing $N$ space-separated integers $A_1, A_2, \ldots, A_N$.

-----Constraints-----
- $1 \le T \le 1,000$
- $1 \le K \le N \le 1,000$

-----Subtasks-----
Subtask #1 (10 points): $N \le 10$
Subtask #2 (90 points): original constraints

-----Example Input-----
1
3 3

-----Example Output-----
1 2 3

Source: codechef | Difficulty: MEDIUM
Tags: Ad-hoc


Solutions:
t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	cnt = n / 2
	diff = n - k
	if k > cnt:
		for i in range(1, n + 1):
			if diff > 0 and i % 2 == 1:
				diff -= 1
				print(-i, end=' ')
			else:
				print(i, end=' ')
	else:
		for i in range(1, n + 1):
			if k > 0 and i % 2 == 0:
				k = k - 1
				print(i, end=' ')
			else:
				print(-i, end=' ')
	print()
	t = t - 1


T = int(input())
for _ in range(T):
	(N, M) = map(int, input().split())
	A = []
	for i in range(N):
		if i % 2 == 0:
			if M > 0:
				A.append(i + 1)
				M -= 1
			else:
				A.append(-i - 1)
		else:
			A.append(-i - 1)
	for i in range(len(A) - 1, -1, -1):
		if M > 0:
			if A[i] < 0:
				A[i] *= -1
				M -= 1
		else:
			break
	print(*A)


import math
tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	ans = []
	for i in range(1, n + 1):
		if i % 2 != 0:
			ans.append(i)
		else:
			ans.append(-i)
	positive = math.ceil(n / 2)
	if positive > k:
		i = n - 1
		diff = positive - k
		while diff > 0:
			if ans[i] > 0:
				ans[i] *= -1
				diff = diff - 1
			i = i - 1
	if positive < k:
		i = n - 1
		diff = k - positive
		while diff > 0:
			if ans[i] < 0:
				ans[i] *= -1
				diff = diff - 1
			i = i - 1
	for i in range(len(ans)):
		print(ans[i], end=' ')


try:
	for _ in range(int(input())):
		arr = list(map(int, input().split()))
		a = []
		s = 0
		for i in range(arr[0]):
			a.append(i + 1)
		if arr[0] % 2 == 0:
			for j in range(arr[0]):
				if a[j] % 2 == 1:
					a[j] = -a[j]
		else:
			for j in range(arr[0]):
				if a[j] % 2 == 0:
					a[j] = -a[j]
		count = 0
		for j in a:
			if j > 0:
				count = count + 1
		if arr[1] > count:
			diff = arr[1] - count
			for j in range(arr[0] - 1, 0 - 1, -1):
				if a[j] < 0 and diff > 0:
					a[j] = -a[j]
					diff = diff - 1
		if arr[1] < count:
			diff = count - arr[1]
			for j in range(arr[0] - 1, -1, -1):
				if a[j] > 0 and diff > 0:
					a[j] = -a[j]
					diff = diff - 1
		for j in a:
			print(j, end=' ')
		print('')
except:
	pass


import math
for t in range(int(input())):
	(n, k) = map(int, input().split())
	lis = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			lis.append(-i)
		else:
			lis.append(i)
	res = math.ceil(n / 2)
	i = len(lis) - 1
	while res < k:
		if lis[i] % 2 == 0:
			lis[i] = i + 1
			res += 1
			i -= 2
		else:
			i -= 1
	j = len(lis) - 1
	while res > k:
		if lis[j] % 2 != 0:
			lis[j] = -(j + 1)
			j -= 2
			res -= 1
		else:
			j -= 1
	print(*lis)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = []
	for i in range(1, n + 1):
		if i % 2 != 0:
			ans.append(i)
		else:
			ans.append(-i)
	posvale = math.ceil(n / 2)
	if posvale > k:
		i = n - 1
		change = posvale - k
		while change > 0:
			if ans[i] > 0:
				ans[i] *= -1
				change = change - 1
			i = i - 1
	if posvale < k:
		i = n - 1
		change = k - posvale
		while change > 0:
			if ans[i] < 0:
				ans[i] *= -1
				change = change - 1
			i = i - 1
	for i in range(len(ans)):
		print(ans[i], end=' ')


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = []
	for i in range(1, n + 1):
		if i % 2 == 1:
			arr.append(i)
		else:
			arr.append(-i)
	v = math.ceil(n / 2)
	if v > k:
		i = n - 1
		j = v - k
		while j > 0:
			if arr[i] > 0:
				arr[i] *= -1
				j -= 1
			i -= 1
	if v < k:
		i = n - 1
		j = k - v
		while j > 0:
			if arr[i] < 0:
				arr[i] *= -1
				j -= 1
			i -= 1
	print(*arr)


import math
try:
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		h = math.ceil(n / 2)
		l = [x * pow(-1, x + 1) for x in range(1, n + 1)]
		if k < h:
			for j in range(2 * k, n):
				l[j] = -abs(l[j])
		elif k > h:
			if l[n - 1] < 0:
				m = n - 1
			else:
				m = n - 2
			for j in range(k - h):
				l[m] = -l[m]
				m = m - 2
		for j in range(n):
			print(l[j], end=' ')
		print()
except:
	pass


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = [0] * a
	for i in range(a):
		arr[i] = i + 1
	x = 0
	b = a - b
	if b > a // 2:
		x = b - a // 2
		b = a // 2
	for i in range(b):
		arr[2 * i + 1] *= -1
	if a % 2 == 0:
		for i in range(x):
			arr[a - 2 * i - 2] *= -1
	if a % 2 != 0:
		for i in range(x):
			arr[a - 2 * i - 1] *= -1
	print(*arr)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = []
	neg = 0
	pos = 0
	for i in range(1, n + 1):
		if k > n // 2:
			if neg < n - k and i % 2 == 1:
				print(-i, end=' ')
				neg += 1
			else:
				print(i, end=' ')
		elif pos < k and i % 2 == 0:
			print(i, end=' ')
			pos += 1
		else:
			print(-i, end=' ')
	print()


import math
t = int(input())
while t:
	(n, k) = map(int, input().split())
	l = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			l.append(-i)
		else:
			l.append(i)
	mid = math.ceil(n / 2)
	if mid > k:
		c = mid - k
		i = n - 1
		while c > 0:
			if l[i] > 0:
				l[i] = l[i] * -1
				c -= 1
			i -= 1
	if mid < k:
		c = k - mid
		j = n - 1
		while c > 0:
			if l[j] < 0:
				l[j] = l[j] * -1
				c -= 1
			j -= 1
	print(*l)
	t -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	for i in range(n):
		if i % 2 == 0:
			arr.append(i + 1)
		else:
			arr.append(-i - 1)
	pos = n // 2 + n % 2
	neg = n // 2
	if k < pos:
		for i in range(n - 1, -1, -1):
			if k == pos:
				break
			if arr[i] > 0:
				arr[i] = -arr[i]
				pos -= 1
	else:
		for i in range(n - 1, -1, -1):
			if k == pos:
				break
			if arr[i] < 0:
				arr[i] = -arr[i]
				pos += 1
	print(*arr)


from math import ceil
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	L = []
	for i in range(1, N + 1):
		if i % 2 == 0:
			L.append(-i)
		else:
			L.append(i)
	C = ceil(N / 2)
	if K <= C:
		d = C - K
		c = 0
		for i in range(N - 1, -1, -1):
			if c == d:
				break
			if L[i] > 0:
				L[i] = -L[i]
				c += 1
	else:
		d = K - C
		c = 0
		for i in range(N - 1, -1, -1):
			if c == d:
				break
			if L[i] < 0:
				L[i] = abs(L[i])
				c += 1
	print(*L)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	output = []
	if k <= n / 2:
		points = 0
		for j in range(1, n + 1):
			if j % 2 == 1 and points < k:
				output.append(j)
				points += 1
			else:
				output.append(-j)
	else:
		points = 0
		for j in range(1, n + 1):
			if j % 2 == 1 and n + 1 - j > k - points:
				output.append(-j)
			else:
				output.append(j)
				points += 1
	print(' '.join(list(map(str, output))))


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


for _ in range(int(input())):
	(n, num_pos) = map(int, input().split())
	num_neg = n - num_pos
	numbers = [x for x in range(1, n + 1)]
	cache = [0] * n
	cache[0] = 1
	count_pos = 1
	count_neg = 0
	i = 1
	while count_pos < num_pos and count_neg < num_neg:
		cache[i] = -cache[i - 1]
		if i % 2 == 0:
			count_pos += 1
		else:
			count_neg += 1
		i += 1
	if count_pos == num_pos:
		cache[i:] = [-1] * (n - i)
	else:
		cache[i:] = [1] * (n - i)
	output = [str(numbers[x] * cache[x]) for x in range(n)]
	print(' '.join(output))


import math
try:
	tc = int(input())
	for _ in range(tc):
		(n, k) = list(map(int, input().split()))
		ans = []
		need = 0
		for i in range(1, n + 1):
			if i % 2 != 0:
				ans.append(i)
			else:
				ans.append(-i)
		p = math.ceil(n / 2)
		need = p - k if p > k else k - p
		if k < p:
			i = n - 1
			while need > 0:
				if ans[i] > 0:
					ans[i] *= -1
					need -= 1
				i -= 1
		if k > p:
			i = n - 1
			while need > 0:
				if ans[i] < 0:
					ans[i] *= -1
					need -= 1
				i -= 1
		print(*ans)
except:
	pass


import math
try:
	t = int(input())
	for _ in range(t):
		(n, k) = list(map(int, input().split()))
		seq = []
		for i in range(1, n + 1):
			if i % 2 != 0:
				seq.append(i)
			else:
				seq.append(-i)
		positive = math.ceil(n / 2)
		if positive > k:
			i = n - 1
			req = positive - k
			while req > 0:
				if seq[i] > 0:
					seq[i] = -(i + 1)
					req -= 1
				i -= 1
		if positive < k:
			i = n - 1
			req = k - positive
			while req > 0:
				if seq[i] < 0:
					seq[i] = i + 1
					req -= 1
				i -= 1
		print(*seq)
except EOFError as t:
	pass


tests = int(input())
for i in range(tests):
	(n, k) = map(int, input().split())
	ans = []
	for j in range(n):
		if j & 1:
			ans.append(-j - 1)
		else:
			ans.append(j + 1)
	negative = n - k
	negative_present = n // 2
	diff = negative - negative_present
	index = n - 1
	while diff > 0:
		if ans[index] > 0:
			ans[index] = -1 * ans[index]
			diff -= 1
		index -= 1
	while diff < 0:
		if ans[index] < 0:
			ans[index] = -1 * ans[index]
			diff += 1
		index -= 1
	print(*ans)


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


for t in range(int(input())):
	(n, k) = map(int, input().split())
	flips = n - k
	A = []
	for i in range(n):
		a = i
		if (i + 1) % 2 == 0 and flips > 0:
			A.append(-(a + 1))
			flips -= 1
		else:
			A.append(a + 1)
	if flips > 0:
		if n % 2:
			last_odd = n - 1
		else:
			last_odd = n - 2
		while flips > 0:
			A[last_odd] *= -1
			flips -= 1
			last_odd -= 2
	print(*A)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	myList = []
	for i in range(1, n + 1):
		myList.append(-i if i % 2 == 0 else i)
	if n % 2 == 0:
		prefixes = n // 2
	else:
		prefixes = n // 2 + 1
	changes = k - prefixes
	if changes < 0:
		count = 0
		for i in range(-1, -n, -1):
			if count == changes:
				break
			if myList[i] > 0:
				myList[i] *= -1
				count -= 1
	else:
		count = 0
		for i in range(-1, -n, -1):
			if count == changes:
				break
			if myList[i] < 0:
				myList[i] *= -1
				count += 1
	for element in myList:
		print(element, end=' ')


t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	ans = list()
	if k <= n / 2:
		count = k
		for i in range(1, n + 1):
			if i % 2 != 0 and count != 0:
				ans.append(i)
				count -= 1
			else:
				ans.append(-i)
	else:
		count = n - k
		for i in range(1, n + 1):
			if i % 2 != 0 and count != 0:
				ans.append(-i)
				count -= 1
			else:
				ans.append(i)
	for n in ans:
		print(n, end=' ')
	print()


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left, bisect_right
mod = 1000000007

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

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

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	(n, k) = In()
	seq = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			seq.append(-i)
		else:
			seq.append(i)
	if k == math.ceil(n / 2):
		print(*seq)
	elif k < math.ceil(n / 2):
		req = abs(k - math.ceil(n / 2))
		for i in range(n - 1, -1, -1):
			if seq[i] > 0:
				seq[i] = -1 * seq[i]
				req -= 1
			if req == 0:
				break
		print(*seq)
	else:
		req = abs(k - math.ceil(n / 2))
		for i in range(n - 1, -1, -1):
			if seq[i] < 0:
				seq[i] = -1 * seq[i]
				req -= 1
			if req == 0:
				break
		print(*seq)

def main():
	for t in range(I()):
		myCode()
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k <= n // 2:
		for i in range(1, 2 * k + 1):
			if i % 2 == 1:
				print(-1 * i, end=' ')
			else:
				print(i, end=' ')
		for i in range(2 * k + 1, n + 1):
			print(-1 * i, end=' ')
	else:
		j = n - k
		for i in range(1, 2 * j + 1):
			if i % 2 == 1:
				print(-1 * i, end=' ')
			else:
				print(i, end=' ')
		for i in range(2 * j + 1, n + 1):
			print(i, end=' ')
	print()


import math
t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	n = a[0]
	k = a[1]
	s = n - k
	d = []
	for i in range(1, a[0] + 1):
		if k > 0 and s > 0:
			if i % 2 == 1:
				d.append(i)
				k -= 1
			else:
				d.append(-i)
				s -= 1
		elif k > 0:
			d.append(i)
			k -= 1
		else:
			d.append(-i)
			s -= 1
	print(*d)


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	if n / 2 > k:
		l = list((-1 * x for x in range(1, n + 1)))
		mark = k
	else:
		l = list(range(1, n + 1))
		mark = n - k
	c = 0
	for i in range(0, n, 2):
		if c == mark:
			break
		l[i] = -1 * l[i]
		c += 1
	print(' '.join((str(x) for x in l)))


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


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		for j in range(1, n + 1):
			print(j, end=' ')
		print()
	else:
		l = []
		a = k
		if k == 1:
			for j in range(1, n + 1):
				if j == 1:
					l.append(j)
				else:
					l.append(-j)
		else:
			for j in range(1, n + 1):
				if j % 2 != 0 and a > 0:
					l.append(j)
					a -= 1
				else:
					l.append(-j)
			if a > 0:
				for j in range(n - 1, -1, -1):
					if a == 0:
						break
					elif l[j] < 0:
						l[j] = -l[j]
						a -= 1
		for j in l:
			print(j, end=' ')
		print()


t = int(input())
import math
while t:
	t = t - 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	l = [-1 * (i + 1) for i in range(n)]
	for i in range(1, n, 2):
		l[i] = l[i] * -1
	if k - math.floor(n / 2) > 0:
		s = k - math.floor(n / 2)
		while s:
			for i in range(n - 1, -1, -1):
				if l[i] < 0:
					l[i] = -1 * l[i]
					s = s - 1
					break
	if math.floor(n / 2) - k > 0:
		s = math.floor(n / 2) - k
		while s:
			for i in range(n - 1, -1, -1):
				if l[i] > 0:
					l[i] = -1 * l[i]
					s = s - 1
					break
	for i in range(n):
		print(l[i], end=' ')


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	arr = []
	for i in range(1, n + 1):
		if i % 2 != 0:
			if k > 0:
				arr.append(i)
				k -= 1
			else:
				arr.append(-i)
		else:
			arr.append(-i)
	if k > 0:
		for i in range(len(arr) - 1, -1, -1):
			if k > 0:
				if arr[i] < 0:
					arr[i] = arr[i] * -1
					k -= 1
	print(*arr)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n == k:
		for i in range(1, n + 1):
			print(i, end=' ')
	else:
		numbers = []
		for i in range(1, n + 1):
			if i % 2 != 0:
				numbers.append(-1 * i)
			else:
				numbers.append(i)
		total_pos = math.ceil(n // 2)
		if total_pos < k:
			b = k - total_pos
			for i in reversed(numbers):
				if b > 0:
					if i < 0:
						numbers[numbers.index(i)] = -1 * i
						b -= 1
				else:
					pass
		if total_pos > k:
			b = total_pos - k
			for i in reversed(numbers):
				if b > 0:
					if i > 0:
						numbers[numbers.index(i)] = -1 * i
						b -= 1
				else:
					pass
		for i in numbers:
			print(i, end=' ')


def calculate(k, n):
	(s, d, inc) = (1, 1, 1)
	l = []
	l.append(0)
	while inc <= n:
		l.append(inc * s)
		if s == 1:
			k -= 1
			if k == 0:
				s *= -1
		if k > 0:
			s *= -1
		inc += 1
	if n % 2 == 0:
		inc -= 1
	else:
		inc -= 2
	while k > 0:
		l[inc] = -1 * l[inc]
		inc -= 2
		k -= 1
	l.remove(0)
	print(*l)
(t, k, n) = (0, 0, 0)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	calculate(k, n)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	pos_cnt = k
	for i in range(1, n + 1):
		if n - k > 0 and i % 2 == 0:
			k += 1
			print(-i, end=' ')
		elif pos_cnt > 0:
			pos_cnt -= 1
			print(i, end=' ')
		else:
			print(-i, end=' ')
	print()


try:
	import math
	tc = int(input())
	for _ in range(tc):
		(n, k) = map(int, input().split())
		ans = []
		for i in range(1, n + 1):
			if i % 2 != 0:
				ans.append(i)
			else:
				ans.append(-i)
		positive = math.ceil(n / 2)
		if positive > k:
			i = n - 1
			needed = positive - k
			while needed > 0:
				if ans[i] > 0:
					ans[i] *= -1
					needed -= 1
				i -= 1
		if positive < k:
			i = n - 1
			needed = k - positive
			while needed > 0:
				if ans[i] < 0:
					ans[i] *= -1
					needed -= 1
				i -= 1
		print(*ans)
except:
	pass


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = list(range(1, n + 1))
	for i in range(1, n, 2):
		arr[i] *= -1
	(pos_px, i) = (math.ceil(n / 2), n - 1)
	while pos_px > k:
		if i % 2 == 0:
			arr[i] *= -1
			pos_px -= 1
		i -= 1
	i = n - 1
	while pos_px < k:
		if i % 2:
			arr[i] *= -1
			pos_px += 1
		i -= 1
	print(*arr)


import math as m
t = int(input())
while t != 0:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	a = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			a.append(-i)
		else:
			a.append(i)
	positive = m.ceil(n / 2)
	if positive > k:
		i = n - 1
		while positive != k:
			if a[i] > 0:
				a[i] *= -1
				positive -= 1
			i -= 1
	else:
		i = n - 1
		while positive != k:
			if a[i] < 0:
				a[i] *= -1
				positive += 1
			i -= 1
	print(*a)
	t -= 1


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	c = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			c.append(-i)
		else:
			c.append(i)
	ans = math.ceil(n / 2)
	if ans > k:
		i = n - 1
		needed = ans - k
		while needed > 0:
			if c[i] > 0:
				c[i] *= -1
				needed -= 1
			i -= 1
	elif ans < k:
		i = n - 1
		needed = k - ans
		while needed > 0:
			if c[i] < 0:
				c[i] *= -1
				needed -= 1
			i -= 1
	print(*c)


test = int(input())
for i in range(test):
	(n, k) = map(int, input().split())
	x = n - k
	for j in range(1, n + 1):
		if j % 2 == 0 and x > 0:
			print(-j, end=' ')
			x -= 1
		elif k <= 0:
			print(-j, end=' ')
		else:
			print(j, end=' ')
			k -= 1
	print()


from math import ceil
t = int(input())
while t:
	l = []
	(n, k) = [int(x) for x in input().split()]
	for i in range(1, n + 1):
		l.append(i) if i % 2 != 0 else l.append(-i)
	x = ceil(n / 2)
	i = n - 1
	if x < k:
		while x != k:
			if l[i] < 0:
				l[i] = -1 * l[i]
				x += 1
			i -= 1
	if x > k:
		while x != k:
			if l[i] > 0:
				l[i] = -1 * l[i]
				x -= 1
			i -= 1
	[print(x, end=' ') for x in l]
	print()
	t = t - 1


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = []
	pos = 0
	for i in range(1, n + 1):
		if i % 2 == 0:
			l.append(-1 * i)
		else:
			l.append(i)
			pos += 1
	if pos < k:
		g = k - pos
		c = 0
		for i in range(n - 1, -1, -1):
			if l[i] < 0:
				l[i] = -1 * l[i]
				c += 1
			if c == g:
				break
	if pos > k:
		g = pos - k
		c = 0
		for i in range(n - 1, -1, -1):
			if l[i] > 0:
				l[i] = -1 * l[i]
				c += 1
			if c == g:
				break
	print(*l)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [j for j in range(1, n + 1)]
	sum_a = 0
	j = 0
	while j < len(a):
		if k > 0:
			sum_a += a[j]
			k -= 1
			j += 1
		elif k == 0:
			if sum_a - a[j] <= 0:
				sum_a -= a[j]
				a[j] = -a[j]
				j += 1
			else:
				m = 1
				while sum_a - a[j] > 0:
					sum_a -= 2 * a[j - m]
					if sum_a <= 0:
						k += 1
					a[j - m] = -a[j - m]
					m += 1
	print(*a)


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


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	arr = [1]
	p = 1
	ne = 0
	m = 0
	for j in range(2, n + 1):
		if j % 2 == 0:
			if p != k:
				arr.append(j)
				p += 1
			else:
				m = 1
				break
		elif ne != n - k:
			arr.append(-j)
			ne += 1
		else:
			m = -1
			break
	if abs(arr[-1]) != n and m == -1:
		for x in range(arr[-1] + 1, n + 1):
			arr.append(x)
	elif abs(arr[-1]) != n and m == 1:
		for x in range(abs(arr[-1]) + 1, n + 1):
			arr.append(-x)
	print(*arr)


import math
t = int(input())
for _ in range(t):
	(N, K) = map(int, input().split())
	ans = []
	for i in range(1, N + 1):
		if i % 2 == 0:
			ans.append(-i)
		else:
			ans.append(i)
	positive = math.ceil(N / 2)
	if positive > K:
		i = N - 1
		needed = positive - K
		while needed > 0:
			if ans[i] > 0:
				ans[i] *= -1
				needed -= 1
			i -= 1
	else:
		i = N - 1
		needed = K - positive
		while needed > 0:
			if ans[i] < 0:
				ans[i] *= -1
				needed -= 1
			i -= 1
	print(*ans)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	for i in range(1, n + 1):
		if i % 2 != 0:
			a.append(i)
		else:
			a.append(-i)
	positive = math.ceil(n / 2)
	needed = abs(positive - k)
	if positive > k:
		i = n - 1
		while needed > 0:
			if a[i] > 0:
				a[i] *= -1
				needed -= 1
			i -= 1
	if positive < k:
		i = n - 1
		while needed > 0:
			if a[i] < 0:
				a[i] *= -1
				needed -= 1
			i -= 1
	print(*a)


test_case = int(input())
for i in range(0, test_case):
	line = input().split(' ')
	N = int(line[0])
	K = int(line[1])
	ans = []
	for i in range(1, N + 1):
		if i % 2 == 0:
			ans.append(0 - i)
		else:
			ans.append(i)
	temp = K - int((N + 1) / 2)
	ind = N - 1
	if temp > 0:
		while temp > 0:
			if ans[ind] < 0:
				ans[ind] = 0 - ans[ind]
				temp = temp - 1
			ind = ind - 1
	else:
		temp = 0 - temp
		while temp > 0:
			if ans[ind] > 0:
				ans[ind] = 0 - ans[ind]
				temp = temp - 1
			ind = ind - 1
	for i in range(0, N):
		print(ans[i], end=' ')
	print()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	po = K
	ne = N - K
	arr = []
	cumsum = 0
	coupo = 0
	coune = 0
	for i in range(N):
		if coupo == K:
			arr.append(-(i + 1))
			coune += 1
			continue
		elif coune == ne:
			arr.append(i + 1)
			coupo += 1
			continue
		a = cumsum + (i + 1)
		b = cumsum - (i + 1)
		if abs(a) > abs(b):
			cumsum = b
			arr.append(-(i + 1))
		else:
			cumsum = a
			arr.append(i + 1)
		if cumsum > 0:
			coupo += 1
		else:
			coune += 1
	for i in range(len(arr)):
		print(arr[i], end=' ')


import sys
import math
import collections
import heapq
import queue
import itertools
import functools
import operator
import time
readline = sys.stdin.readline
IPS = lambda : readline().rstrip()
IP = lambda : int(readline().rstrip())
MP = lambda : map(int, readline().split())
LS = lambda : list(map(int, readline().split()))
AR = lambda : [int(x) for x in readline().split()]

def solve():
	for _ in range(IP()):
		(n, k) = MP()
		ans = [-x for x in range(1, n + 1)]
		ans[0] = -ans[0]
		k -= 1
		(i, j) = (1, -1)
		if n & 1 == 1:
			j = n - 1
		else:
			j = n - 2
		while k > 0:
			if i < n:
				ans[i] = -ans[i]
				i += 2
			elif j > 0:
				ans[j] = -ans[j]
				j -= 2
			k -= 1
		for a in ans:
			print(a, end=' ')
		print()

def __starting_point():
	solve()
__starting_point()


T = int(input())
ans = []
for _ in range(T):
	(N, K) = [int(i) for i in input().split()]
	A = []
	count = 0
	for i in range(1, N + 1):
		if i % 2 == 0:
			A.append(i)
			count += 1
		else:
			A.append(-i)
	e = K - count
	if e > 0:
		for i in range(N - 1, -1, -1):
			if A[i] < 0 and e > 0:
				e -= 1
				A[i] *= -1
			if e == 0:
				break
	elif e < 0:
		for i in range(N - 1, -1, -1):
			if A[i] > 0 and e < 0:
				e += 1
				A[i] *= -1
			if e == 0:
				break
	s = ''
	for i in range(N):
		s += str(A[i]) + ' '
	ans.append(s)
for i in ans:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr = []
	if k <= n / 2:
		for i in range(1, n + 1):
			if i <= 2 * k and i % 2 == 1:
				arr.append(i)
			else:
				arr.append(-i)
	else:
		for i in range(1, n + 1):
			if i <= 2 * (n - k) and i % 2 == 0:
				arr.append(-i)
			else:
				arr.append(i)
	print(*arr)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	a = []
	for i in range(1, n + 1):
		if i % 2 == 1:
			a.append(i)
		else:
			a.append(-i)
	if n % 2 == 0:
		b = n // 2
	else:
		b = n // 2 + 1
	if b > k:
		f = b - k
		for i in range(n - 1, -1, -1):
			if a[i] > 0:
				a[i] = -a[i]
				f -= 1
			if f == 0:
				break
	if b < k:
		f = k - b
		for i in range(n - 1, -1, -1):
			if a[i] < 0:
				a[i] = -a[i]
				f -= 1
			if f == 0:
				break
	for i in a:
		print(i, end=' ')
	print()


try:
	for _ in range(int(input())):
		(N, K) = map(int, input().split())
		arr = [int(i) for i in range(1, N + 1)]
		count = N - K
		res = []
		s = ' '
		if N == K:
			pass
		else:
			track = 0
			for j in range(0, N, 2):
				if track >= count:
					break
				arr[j] = arr[j] * -1
				track += 1
			if len(arr) % 2 == 0:
				c = N - 1
			else:
				c = N - 2
			for i in range(c, 0, -2):
				if track >= count:
					break
				arr[i] = arr[i] * -1
				track += 1
		for i in arr:
			res.append(str(i))
		print(s.join(res))
except:
	pass


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	li = []
	for i in range(n):
		li.append((i + 1) * (-1) ** i)
	l = n // 2 + n % 2
	if k > l:
		x = n - n % 2 - 1
		y = x - 2 * (k - l)
		for j in range(x, y, -2):
			li[j] = -li[j]
	else:
		x = n - 1 + n % 2 - 1
		y = x - 2 * (l - k)
		for j in range(x, y, -2):
			li[j] = -li[j]
	print(*li)


import math
T = int(input(''))
for i in range(T):
	(N, K) = map(int, input().split())
	s = N - K
	l = []
	for i in range(1, N + 1):
		if K > 0 and s > 0:
			if i % 2 == 1:
				l.append(i)
				K -= 1
			else:
				l.append(-i)
				s -= 1
		elif K > 0:
			l.append(i)
			K -= 1
		else:
			l.append(-i)
			s -= 1
	print(*l)


def positive_prefix(n, k):
	a = []
	for i in range(n):
		if i % 2 == 0:
			a.append(i + 1)
		else:
			a.append(-1 * (i + 1))
	pn = int(n / 2) + int(n % 2)
	loc = n - 1
	if k > pn:
		while k != pn:
			if a[loc] < 0:
				a[loc] = -a[loc]
				pn = pn + 1
			loc = loc - 1
	else:
		while k != pn:
			if a[loc] > 0:
				a[loc] = -a[loc]
				pn = pn - 1
			loc = loc - 1
	a = ' '.join((str(i) for i in a))
	return a
t = int(input())
while t:
	t = t - 1
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	print(positive_prefix(n, k))


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	L = [i for i in range(1, N + 1)]
	for i in range(1, N, 2):
		L[i] = -L[i]
	current_K = (N + 1) // 2
	diff = current_K - K
	L = list(reversed(L))
	if diff < 0:
		if N % 2 == 0:
			for i in range(-diff):
				L[2 * i] = -L[2 * i]
		else:
			for i in range(-diff):
				L[2 * i + 1] = -L[2 * i + 1]
	elif N % 2 == 0:
		for i in range(diff):
			L[2 * i + 1] = -L[2 * i + 1]
	else:
		for i in range(diff):
			L[2 * i] = -L[2 * i]
	for i in reversed(L):
		print(i, end=' ')
	print()


for i in range(int(input())):
	(N, K) = map(int, input().split())
	a = []
	if N == K:
		for i in range(1, N + 1):
			a.append(i)
	elif K > N - K:
		j = 0
		c = 1
		while c < N + 1:
			if j < N - K:
				a.append(c)
				c += 1
				c = -c
				a.append(c)
				c = -c
				j += 1
				c += 1
			else:
				a.append(c)
				c += 1
	elif K < N - K:
		j = 0
		c = 1
		while c < N + 1:
			if j < K:
				a.append(c)
				c += 1
				c = -c
				a.append(c)
				c = -c
				j += 1
				c += 1
			else:
				c = -c
				a.append(c)
				c = -c
				c += 1
	else:
		c = 1
		while c < N + 1:
			a.append(c)
			c += 1
			c = -c
			a.append(c)
			c = -c
			c += 1
	print(*a)


import sys

def solve(n, k):
	arr = []
	prefix = []
	for i in range(1, n + 1):
		if i % 2:
			arr.append(i)
		else:
			arr.append(-i)
	k_count = n // 2 + n % 2
	diff = abs(k - k_count)
	if k < k_count:
		for i in range(n - 1, -1, -1):
			if diff == 0:
				break
			if arr[i] > 0:
				arr[i] *= -1
				diff -= 1
	elif k > k_count:
		for i in range(n - 1, -1, -1):
			if diff == 0:
				break
			if arr[i] < 0:
				arr[i] *= -1
				diff -= 1
	print(*arr, 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, k) = list(map(int, input().split()))
	solve(n, k)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	a = list()
	if 2 * k <= n:
		for i in range(2 * k):
			if i % 2 == 0:
				a.append(i + 1)
			else:
				a.append(-i - 1)
		for i in range(2 * k, n, 1):
			a.append(-i - 1)
	elif 2 * k > n:
		for i in range(2 * (n - k)):
			if i % 2 == 0:
				a.append(i + 1)
			else:
				a.append(-i - 1)
		for i in range(2 * (n - k), n, 1):
			a.append(i + 1)
	else:
		for i in range(2 * k):
			if i % 2 == 0:
				a.append(i + 1)
			else:
				a.append(-i - 1)
	for i in a:
		print(i, end=' ')
	t -= 1


t = int(input())
for m in range(t):
	(n, k) = list(map(int, input().split()))
	if n == k:
		l = [x for x in range(1, n + 1)]
		print(*l)
	else:
		l = []
		for i in range(1, n + 1):
			if i % 2 == 0:
				l.append(i)
			else:
				l.append(-i)
		val = n // 2
		if k == val:
			print(*l)
		else:
			if k > val:
				if n % 2 == 0:
					j = n - 2
				else:
					j = n - 1
				val = k - val
			else:
				if n % 2 == 0:
					j = n - 1
				else:
					j = n - 2
				val = val - k
			for i in range(val):
				l[j] = -l[j]
				j -= 2
			print(*l)


for t in range(int(input())):
	(n, k) = (int(i) for i in input().split())
	ar1 = list((i for i in range(1, n + 1)))
	kdash = n - k
	for i in range(0, len(ar1), 2):
		if kdash != 0:
			kdash -= 1
			ar1[i] = 0 - ar1[i]
		else:
			break
	if kdash != 0:
		for i in reversed(range(1, len(ar1), 2)):
			if kdash != 0:
				kdash -= 1
				ar1[i] = 0 - ar1[i]
	for elem in ar1:
		print(elem, end=' ')
	print()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	cumsum = 0
	coupo = 0
	coune = 0
	for i in range(N):
		if coupo == K:
			print(-(i + 1), end=' ')
			coune += 1
			continue
		elif coune == N - K:
			print(i + 1, end=' ')
			coupo += 1
			continue
		a = cumsum + (i + 1)
		b = cumsum - (i + 1)
		if abs(a) > abs(b):
			cumsum = b
			print(-(i + 1), end=' ')
		else:
			cumsum = a
			print(i + 1, end=' ')
		if cumsum > 0:
			coupo += 1
		else:
			coune += 1