Given an even integer N, output a *permutation* P of length N, such that:
The value of P_{i} + P_{N+1-i} is distinct for all 1 ≤ i ≤ \frac{N}{2}.

It is guaranteed that a possible solution always exists. If multiple such permutations exist, print any.

Note that, a permutation P of length N, consists of all integers from 1 to N exactly once. For example, [2, 1, 3, 4] is a permutation, while [2, 2, 1, 3] is not.

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

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of a single line containing a single even integer N.

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

For each test case, output N space-separated integers, denoting the permutation P of length N.

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

$1 ≤ T ≤ 1000$
$2 ≤ N ≤ 2000$
$N$ is even.

----- Sample Input 1 ------ 
3
2
6
4

----- Sample Output 1 ------ 
2 1
1 3 2 4 5 6
2 1 3 4

----- explanation 1 ------ 
Test case $1$: Consider the permutation $P = [2, 1]$.  
The value $P_{i} + P_{N+1-i} = 2 + 1 = 3$ for $i = 1$, which is distinct.

Test case $2$: Consider the permutation $P = [1, 3, 2, 4, 5, 6]$.  
- For $i = 1$: The value $P_{i} + P_{N+1-i} = 1 + 6 = 7$.
- For $i = 2$: The value $P_{i} + P_{N+1-i} = 3 + 5 = 8$.
- For $i = 3$: The value $P_{i} + P_{N+1-i} = 2 + 4 = 6$.

Thus, the values are distinct for each $1 ≤ i ≤ \frac{N}{2}$.

Test case $3$: Consider the permutation $P = [2, 1, 3, 4]$.  
- For $i = 1$: The value $P_{i} + P_{N+1-i} = 2 + 4 = 6$.
- For $i = 2$: The value $P_{i} + P_{N+1-i} = 1 + 3 = 4$.

Thus, the values are distinct for each $1 ≤ i ≤ \frac{N}{2}$.

Difficulty: EASY
Tags: Constructive algorithms

Starter code:

Solutions:
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(n // 2, 0, -1):
		a.append(i)
	for j in range(n // 2 + 1, n + 1):
		a.append(j)
	print(*a)


for u in range(int(input())):
	n = int(input())
	l = []
	kk = []
	for j in range(1, n // 2 + 1):
		l.append(j)
	for k in range(n // 2 + 1, n + 1):
		kk.append(k)
	for w in range(n // 2):
		kk.append(l[-1 - w])
	print(*kk)


for k in range(int(input())):
	a = int(input())
	n = a // 2
	x = list(range(1, n + 1))
	y = list(range(a, n, -1))
	print(*x + y)


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2):
		a.append(i)
	for j in range(n // 2, n + 1):
		b.append(j)
	p = b[::-1]
	su = a + p
	print(*su)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(range(1, n + 1, 2))
	b = list(range(2, n + 1, 2))
	l = a[::-1] + b
	print(*l)


t = int(input())
for _ in range(t):
	n = int(input())
	L = list(range(1, n + 1, 2))
	R = list(range(2, n + 1, 2))
	A = L[::-1] + R
	print(*A)


import sys
sys.setrecursionlimit(10 ** 7)
mod = 10 ** 9 + 7

def readInt():
	return int(input())

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

def readStringList():
	return list(input())

def readStringListWithSpace():
	return list(input().split())

def readString():
	return input()
import math

def execute():
	for _ in range(readInt()):
		n = readInt()
		arr = [i for i in range(1, n + 1)]
		arr = arr[:n // 2] + arr[n // 2:][::-1]
		print(*arr)
execute()


from itertools import permutations
t = int(input())
for i in range(t):
	p = int(input())
	a = []
	b = []
	for i in range(1, p // 2):
		a.append(i)
	for j in range(p // 2, p + 1):
		b.append(j)
	tu = b[::-1]
	print(*a + tu)


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


for t in range(int(input())):
	n = int(input())
	c = []
	for i in range(1, n + 1):
		c.append(i)
	a = c[:n // 2]
	b = c[n // 2:n]
	a = a[::-1]
	print(*a, *b)


t = int(input())
for i in range(t):
	my = []
	my1 = []
	n = int(input())
	for i in range(1, n + 1, 2):
		my.append(i)
	for j in range(2, n + 1, 2):
		my1.append(j)
	R = my[::-1] + my1
	print(*R)


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = []
	l2 = []
	for i in range(1, n // 2):
		l1.append(i)
	for i in range(n // 2, n + 1):
		l2.append(i)
	l2.reverse()
	l = l1 + l2
	print(*l)


class Mode:

	def __init__(self, n):
		arrA = [i for i in range(1, n // 2)]
		arrB = [i for i in range(n // 2, n + 1)]
		self.arr = arrA + arrB[::-1]

	def Solution(self):
		print(*self.arr)

def main():
	for _ in range(int(input())):
		n = int(input())
		ans = Mode(n)
		ans.Solution()
main()


for i in range(int(input())):
	n = int(input())
	freq = {}
	for x in range(1, n + 1):
		freq[x] = 1
		m = n
	for i in range(1, n, 2):
		print(i, m, end=' ')
		m -= 2
	print()


for i in range(int(input())):
	n = int(input())
	for i in range(n // 2, 0, -1):
		print(i, end=' ')
	for i in range(n // 2 + 1, n + 1, 1):
		print(i, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	arr = [x for x in range(1, n + 1)]
	first = arr[:len(arr) // 2]
	second = arr[len(arr) // 2:]
	arr = first[::-1] + second
	for i in arr:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = [i for i in range(1, n // 2 + 1)]
	m = [i for i in range(n, n // 2, -1)]
	l = l + m
	print(*l)


for i in range(int(input())):
	n = int(input())
	l = []
	for i in range(1, n + 1):
		l.append(i)
	middle = len(l) // 2
	l1 = list(l[:middle])
	l2 = list(l[middle:])
	l1.reverse()
	for i in range(len(l1)):
		print(l1[i], end=' ')
	for i in range(len(l2)):
		print(l2[i], end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	(i, j) = (1, n)
	while i < j:
		print(i, j, end=' ')
		i += 1
		j -= 1
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [i for i in range(1, n // 2 + 1)]
	b = [i for i in range(n, n // 2, -1)]
	res = a + b
	print(*res)


import math
for t in range(int(input())):
	n = int(input())
	lst1 = []
	lst2 = []
	for x in range(1, n + 1):
		if x % 2 == 0:
			lst2.append(str(x))
		else:
			lst1.append(str(x))
	lst2.reverse()
	ans = lst1 + lst2
	print(' '.join(ans))


T = int(input())
for i in range(T):
	N = int(input())
	a = N // 2
	for i in range(a + 1, N + 1):
		print(i, end=' ')
	for i in range(a, 0, -1):
		print(i, end=' ')
	print()


x = int(input())
tr = []
for ii in range(0, x):
	gh = int(input())
	tr.append(gh)
for nnc in tr:
	rf = []
	for nnd in range(1, nnc + 1):
		rf.append(str(nnd))
	klo = rf[0:nnc // 2]
	ppr = rf[nnc // 2:]
	ppr.reverse()
	klo = klo + ppr
	hhh = ' '.join(klo)
	print(hhh)


for _ in range(int(input())):
	x = int(input())
	p = []
	q = []
	for i in range(1, x // 2):
		p.append(i)
	for j in range(x // 2, x + 1):
		q.append(j)
	t = q[::-1]
	tot = p + t
	print(*tot)


for t in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2 + 1):
		a.append(i)
	for i in range(n // 2 + 1, n + 1):
		b.append(i)
	b.reverse()
	ans = a + b
	print(*ans)


vojj = int(input())
for vishnesh in range(vojj):
	n = int(input())
	a2 = []
	a1 = []
	for i in range(n // 2 + 1, n + 1):
		a2.append(i)
	for i in range(n // 2, 0, -1):
		a1.append(i)
	a2 = a1 + a2
	for i in a2:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(range(1, n + 1, 2)) + list(range(2, n + 1, 2))[::-1]
	print(*l)


for _ in range(int(input())):
	n = int(input())
	st = 1
	en = n
	i = 0
	j = n - 1
	l = [0] * n
	while i < j:
		l[i] = st
		st += 1
		i += 1
		l[j] = st
		st += 1
		j -= 1
	for k in l:
		print(k, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l = [a for a in range(1, n + 1)]
	e = []
	o = []
	for j in l:
		if j % 2 == 0:
			e.append(j)
		else:
			o.append(j)
	o.reverse()
	l = e + o
	print(*l)


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2:
		print(-1)
	else:
		e = [x for x in range(2, n + 1, 2)]
		l = [x for x in range(1, n, 2)]
		l.reverse()
		e = e + l
		print(*e)


t = int(input())
for _ in range(t):
	a = []
	n = int(input())
	for i in range(n):
		a.append(i + 1)
	n1 = n // 2
	a[0:n1] = a[n1 - 1::-1]
	print(' '.join((str(i) for i in a)))


for _ in range(int(input())):
	n = int(input())
	for i in range(1, n // 2 + 1):
		print(i, end=' ')
	for i in range(n, n // 2, -1):
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	x = list(range(n // 2, 0, -1)) + list(range(n // 2 + 1, n + 1))
	print(' '.join(map(str, x)))


t = int(input())
for cases in range(t):
	n = int(input())
	ans = [i if i <= n // 2 else 3 * n // 2 + 1 - i for i in range(1, n + 1)]
	print(' '.join(map(str, ans)))


from math import *
for i in range(int(input())):
	n = int(input())
	p = [i for i in range(1, n + 1)]
	s = p[:int(n / 2)]
	t = p[int(n / 2):]
	p = s[::-1] + t
	print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	p = list(range(1, n + 1))
	p = p[n // 2 - 1::-1] + p[n // 2::1]
	for j in p:
		print(j, end=' ')
	print()


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	for j in range(1, n + 1):
		if j <= n / 2:
			a = [j] + a
		else:
			a = a + [j]
	for j in a:
		print(j, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	l = list(range(1, n + 1, 2))
	m = list(range(2, n + 1, 2))
	a = l[::-1] + m
	print(*a)


for i in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2):
		a.append(i)
	for j in range(n // 2, n + 1):
		b.append(j)
	c = b[::-1]
	ans = a + c
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	for j in range(n // 2, 0, -1):
		print(j, end=' ')
	for k in range(n // 2 + 1, n + 1):
		print(k, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	ans = []
	for j in range(1, n, 2):
		ans.append(j)
	for k in range(n, 0, -2):
		ans.append(k)
	for i in ans:
		print(i, end=' ')
	print()


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	i = 0
	for _ in range(n // 2):
		a.append(n - i)
		a.append(i + 1)
		i += 1
	if n % 2:
		a.append(n - i)
	for j in a:
		print(j, end=' ')
	print()


for _ in range(int(input())):
	x = []
	y = []
	n = int(input())
	for i in range(1, n + 1):
		if i % 2 == 0:
			x.append(str(i))
		else:
			y.append(str(i))
	x = x[::-1]
	print(' '.join(x) + ' ' + ' '.join(y))


t = int(input())
while t:
	n = int(input())
	arr = [0] * n
	j = 0
	for i in range(1, n + 1, 2):
		arr[j] = i + 1
		arr[n - 1 - j] = i
		j += 1
	print(' '.join(map(str, arr)))
	t -= 1


T = int(input(''))
for i in range(T):
	N = int(input(''))
	n = N / 2
	lst = []
	for i in range(N):
		if n > i:
			lst.append(int(n - i))
		elif i >= n:
			lst.append(i + 1)
	print(*lst)


t = int(input())
for i in range(t):
	x = int(input())
	lis = list(range(1, x // 2 + 1))
	lis_1 = list(range(x, x // 2, -1))
	print(*lis + lis_1)


t = int(input())
for i in range(t):
	x = int(input())
	lis = list(range(1, x + 1, 2))
	lis_2 = list(range(2, x + 1, 2))
	lis_2.reverse()
	print(*lis + lis_2)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(range(1, n + 1, 2))
	b = list(range(2, n + 1, 2))
	b.reverse()
	c = a + b
	print(*c)


for i in range(int(input())):
	a = int(input())
	d = a
	b = []
	for i in range(1, a // 2 + 1):
		b.append(i)
		b.append(d)
		d = d - 1
	print(*b)


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2):
		a.append(i)
	for j in range(n // 2, n + 1):
		b.append(j)
	m = b[::-1]
	sui = a + m
	print(*sui)


t = int(input())
for i in range(t):
	n = int(input())
	a = [i for i in range(n // 2, 0, -1)] + [i for i in range(n // 2 + 1, n + 1)]
	print(*a)


for _ in range(int(input())):
	n = int(input())
	r = [0] * n
	i = 0
	j = 1
	while i < n // 2:
		r[i] = j
		r[n - i - 1] = j + 1
		j += 2
		i += 1
	for x in r:
		print(x, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(1, n + 1):
		if i % 2 == 0:
			a.append(i)
		else:
			a.append(n - i)
	for i in a:
		print(i, end=' ')
	print(' ')


for i in range(int(input())):
	x = int(input())
	arr = []
	for a in range(x):
		arr.append(0)
	for j in range(x):
		if j % 2 == 0:
			arr[int(j / 2)] = j + 1
		else:
			arr[-int((j + 1) / 2)] = j + 1
	for g in arr:
		print(g, end=' ')
	print()


t = int(input())
for fdhj in range(t):
	n = int(input())
	arr = [n // 2 - i for i in range(0, n // 2)]
	arr2 = [j for j in range(n // 2 + 1, n + 1)]
	arr.extend(arr2)
	for x in arr:
		print(x, end=' ')
	print('')


t = int(input())
while t != 0:
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2):
		a.append(i)
	for j in range(n // 2, n + 1):
		b.append(j)
	p = b[::-1]
	su = a + p
	print(*su)
	t -= 1


t = int(input())
while t != 0:
	n = int(input())
	llstr = ''
	i = n
	while i >= 1:
		if i != 0 or i != 1:
			llstr += str(i) + ' '
		else:
			break
		i -= 2
	if i == 0:
		i = 1
		while i < n:
			if i != n - 1:
				llstr += str(i) + ' '
			else:
				llstr += str(i)
			i += 2
	else:
		i = 2
		while i < n:
			if i != n - 1:
				llstr += str(i) + ' '
			else:
				llstr += str(i)
			i += 2
	print(llstr.strip())
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	for i in range(1, n + 1, 2):
		print(i, end=' ')
	for i in range(n, 1, -2):
		print(i, end=' ')
	print()


for _ in range(int(input())):
	N = int(input())
	a = [i + 1 for i in range(N // 2)]
	a += [i + 1 for i in reversed(range(N // 2, N))]
	print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	x = list(range(1, n + 1, 2))
	y = list(range(2, n + 1, 2))
	z = x[::-1] + y
	print(*z)


T = int(input())
for i in range(T):
	n = int(input())
	a = []
	b = []
	for j in range(1, n // 2):
		a.append(j)
	for k in range(n // 2, n + 1):
		b.append(k)
	p = b[::-1]
	su = a + p
	print(*su)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(range(1, n + 1, 2))
	m = list(range(2, n + 1, 2))
	w = s[::-1] + m
	print(*w)


v = int(input())
for i in range(0, v):
	n = int(input())
	a = list(range(1, n + 1, 2))
	p = list(range(2, n + 1, 2))
	l = a[::-1] + p
	print(*l)


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, n // 2):
		a.append(i)
	for j in range(n // 2, n + 1):
		b.append(j)
	t = b[::-1]
	su = a + t
	for ele in su:
		print(ele, end=' ')
	print()


import bisect
import math
import sys
import collections
from collections import Counter, defaultdict, deque
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	ans = []
	for i in range(1, n // 2 + 1):
		ans.append(i)
	ans += [i for i in reversed(range(n // 2 + 1, n + 1))]
	print(*ans)