You are given one integer $n$ ($n > 1$).

Recall that a permutation of length $n$ is an array consisting of $n$ distinct integers from $1$ to $n$ in arbitrary order. For example, $[2, 3, 1, 5, 4]$ is a permutation of length $5$, but $[1, 2, 2]$ is not a permutation ($2$ appears twice in the array) and $[1, 3, 4]$ is also not a permutation ($n = 3$ but there is $4$ in the array).

Your task is to find a permutation $p$ of length $n$ that there is no index $i$ ($1 \le i \le n$) such that $p_i = i$ (so, for all $i$ from $1$ to $n$ the condition $p_i \ne i$ should be satisfied).

You have to answer $t$ independent test cases.

If there are several answers, you can print any. It can be proven that the answer exists for each $n > 1$.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 100$) — the number of test cases. Then $t$ test cases follow.

The only line of the test case contains one integer $n$ ($2 \le n \le 100$) — the length of the permutation you have to find.


-----Output-----

For each test case, print $n$ distinct integers $p_1, p_2, \ldots, p_n$ — a permutation that there is no index $i$ ($1 \le i \le n$) such that $p_i = i$ (so, for all $i$ from $1$ to $n$ the condition $p_i \ne i$ should be satisfied).

If there are several answers, you can print any. It can be proven that the answer exists for each $n > 1$.


-----Examples-----

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


-----Note-----

None

Source: codeforces | Difficulty: EASY
Tags: Constructive algorithms

Probability


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


import sys
input = lambda : sys.stdin.readline().strip()
for _ in ' ' * int(input()):
	n = int(input())
	count = []
	for i in range(2, n + 1):
		count.append(i)
	count.append(1)
	print(*count)


T = int(input())
for _ in range(T):
	x = int(input())
	out = [x] + list(range(1, x))
	print(' '.join(map(str, out)))


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


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


for _ in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		print(*[i for i in range(n, 0, -1)])
	else:
		arr = [i for i in range(n, 0, -1)]
		i = (n + 1) // 2
		arr[0] = i
		arr[i - 1] = n
		print(*arr)


n = int(input())
N_list = list()

def do_fun(n):
	if n == 2:
		print('2 1')
	else:
		for j in range(n, n // 2 + 1, -1):
			if j != 0:
				print(j, end=' ')
		for i in range(1, n // 2 + 2):
			if i != 0:
				print(i, end=' ')
		print()
for i in range(0, n):
	y = int(input())
	N_list.append(y)
for j in range(0, n):
	do_fun(N_list[j])


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


for i in range(int(input())):
	n = int(input())
	print(*list(range(2, n + 1)), 1)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [str(n) + ' ']
	for i in range(1, n):
		arr.append(str(i) + ' ')
	print(''.join(arr))


def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))
t = int(input())
for _ in range(t):
	n = int(input())
	oneLineArrayPrint([n] + list(range(1, n)))


for _ in range(int(input())):
	n = int(input())
	result = list(range(1, n + 1))
	result.reverse()
	if n % 2 == 1:
		aux = result[n // 2]
		result[n // 2] = result[0]
		result[0] = aux
	print(*result)


import math
t = int(input())
for i in range(0, t):
	n = int(input())
	list1 = []
	for x in range(1, n + 1):
		list1.append(x)
	list1 = sorted(list1, reverse=True)
	if n <= 2:
		print(*list1)
	else:
		middleIndex = len(list1) // 2
		(list1[0], list1[middleIndex]) = (list1[middleIndex], list1[0])
		print(*list1)


for i in range(int(input())):
	n = int(input())
	m = [j for j in range(1, n + 1)]
	p = len(m) - 1
	for k in range(-1, p, 1):
		print(m[k], end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	l = list(range(1, n + 1))
	l.sort(reverse=True)
	if n % 2 != 0:
		mid = n // 2
		k = l[mid]
		l[mid] = l[-1]
		l[-1] = k
	print(*l)


for nt in range(int(input())):
	n = int(input())
	if not n % 2:
		print(*[i for i in range(1, n + 1)][::-1])
	else:
		ans = [i for i in range(1, n + 1)]
		ans = ans[::-1]
		(ans[0], ans[n // 2]) = (ans[n // 2], ans[0])
		print(*ans)


t = int(input())
l = []
for i in range(0, t):
	m = int(input())
	l.append(m)
for j in range(0, t):
	n = l[j]
	k = [0] * n
	k[0] = n
	for p in range(1, n):
		k[p] = p
	print(*k, ' ')


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


cases = int(input())
while cases:
	cases -= 1
	n = int(input())
	numbers = list(range(1, n + 1))
	temp = numbers[0]
	numbers.pop(0)
	numbers.append(temp)
	result = ''
	for num in numbers:
		result += str(num) + ' '
	print(result)


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for i in range(n, 0, -1):
		l.append(i)
	if n % 2 == 0:
		print(*l)
	else:
		(l[n // 2], l[n // 2 + 1]) = (l[n // 2 + 1], l[n // 2])
		print(*l)


n = int(input())
for i in range(n):
	k = int(input())
	out = []
	for j in range(2, k + 1):
		out.append(j)
	out.append(1)
	for e in out:
		print(e, end=' ')
	print()


import math
for i in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		for i in range(n, 0, -1):
			if i == 1:
				print(i)
			else:
				print(i, end=' ')
	else:
		nn = n
		if n == 3:
			print('3 1 2')
		else:
			for i in range(0, n // 2):
				print(n, end=' ')
				n -= 1
			print(math.floor(nn / 2), math.ceil(nn / 2), sep=' ', end=' ')
			for j in range(int(math.floor(nn / 2)) - 1, 0, -1):
				if j == 1:
					print(j)
				else:
					print(j, end=' ')


t = int(input())
for i in range(t):
	n = int(input())
	print(' '.join([str(x % n + 1) for x in range(1, n + 1)]))


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

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

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

def solve():
	n = int(inputi())
	res = [n] + list(range(1, n))
	print(' '.join(map(str, res)))

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


def solve():
	n = int(input())
	half = n // 2
	ans = [str(i) for i in range(half + 1, n + 1)] + [str(i) for i in range(half, 0, -1)]
	print(' '.join(ans))
tc = int(input())
while tc > 0:
	tc -= 1
	solve()


n = int(input())
for x in range(n):
	t = int(input())
	S = ''
	for i in range(t - 1):
		S += str(i + 2) + ' '
	S += '1'
	print(S)


for _ in range(int(input())):
	n = int(input())
	a = [n]
	for i in range(1, n):
		a.append(i)
	print(*a)


for _ in range(int(input())):
	n = int(input())
	li = []
	for i in range(1, n + 1):
		if i == n:
			li.append(1)
		else:
			li.append(i + 1)
	print(*li)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

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

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

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

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

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None
t = N()
for i in range(t):
	n = N()
	ans = []
	for i in range(n):
		if i == 0:
			ans.append(n)
		else:
			ans.append(i)
	print(*ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [i for i in range(1, n + 1)]
	a.reverse()
	if n % 2 == 1:
		b = a[0]
		a[0] = a[n // 2]
		a[n // 2] = b
	print(*a, ' ')


t = int(input())
for i in range(t):
	n = int(input())
	l = []
	for j in range(n + 1, 0, -1):
		l.append(j)
	for j in range(1, len(l)):
		if l[j] == j:
			(l[j], l[j + 1]) = (l[j + 1], l[j])
	for j in range(1, len(l)):
		print(l[j], end=' ')
	print('\n')


n = int(input())
l = list()
for i in range(n):
	m = int(input())
	l.append(m)
	for p in range(1, m):
		l.append(p)
	print(*l)
	l.clear()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	for x in range(2, n + 1):
		print(x, end=' ')
	print(1)


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


class main:
	n = int(input())
	d = []
	for i in range(n):
		a = int(input())
		b = []
		a1 = str(a)
		b.append(a1)
		count = 1
		for j in range(a - 1):
			counts = str(count)
			b.append(counts)
			count += 1
		c = ' '.join(b)
		d.append(c)
	e = '\n'.join(d)
	print(e)


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


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


n = int(input())
while n:
	n -= 1
	k = int(input())
	t = []
	for i in range(k - 1):
		t.append(f'{i + 2}')
	t.append(f'1')
	print(' '.join(t))


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


for _ in range(int(input())):
	n = list(range(1, int(input()) + 1))
	if len(n) % 2:
		n = n[len(n) // 2:] + n[:len(n) // 2]
	else:
		n = n[len(n) // 2:] + n[:len(n) // 2]
	print(*n)


for t in range(int(input())):
	n = int(input())
	print(n, *range(1, n))


for _ in range(int(input())):
	ls = []
	length = int(input())
	ls.append(length)
	for i in range(1, length):
		ls.append(i)
	print(' '.join(map(str, ls)))


t = int(input())
for l in range(t):
	n = int(input())
	A = [x + 2 for x in range(n)]
	A[n - 1] = 1
	print(*A)


def solve(n):
	a = [0] * n
	a[0] = n
	for i in range(1, n):
		a[i] = i
	return a
t = int(input())
ans = []
while t > 0:
	n = int(input(''))
	ans.append(solve(n))
	t -= 1
for i in ans:
	for j in i:
		print(j, end=' ')
	print()


n = int(input())
for i in range(n):
	list1 = []
	num = int(input())
	for j in range(1, num + 1):
		list1.append(j)
	if len(list1) % 2 == 0:
		print(*sorted(list1, reverse=True))
	else:
		val = list1[0]
		list1.pop(0)
		list1.append(val)
		print(*list1)


t = int(input(''))
for i in range(t):
	n = int(input(''))
	temp = n
	temp_holder = str()
	k = 1
	if n > 2:
		while n != temp // 2 + 1:
			temp_holder += str(n) + ' '
			n -= 1
		while k <= n:
			temp_holder += str(k) + ' '
			k += 1
	elif n == 2:
		print(2, 1)
	elif n == 1:
		print(1)
	print(temp_holder)


for _ in range(int(input())):
	x = int(input())
	ans = []
	if x % 2:
		ans = [x - i - 1 if i < x // 2 else x - i if i > x // 2 else x for i in range(x)]
	else:
		ans = [x - i for i in range(x)]
	print(' '.join(map(str, ans)))


for i in range(int(input())):
	a = int(input())
	for j in range(2, a + 1):
		print(j, end=' ')
	print(1)
	print()


for _ in range(int(input())):
	x = int(input())
	l = list(range(1, x + 1))[::-1]
	if x % 2 == 1:
		l.remove(x // 2 + 1)
		l.append(x // 2 + 1)
	print(*l)


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


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	listnum = [x for x in range(n, 0, -1)]
	if n % 2 != 0:
		temp = listnum[n // 2]
		listnum[n // 2] = listnum[-1]
		listnum[-1] = temp
	ans.append(tuple(map(str, listnum)))
for case in ans:
	print(' '.join(case))


import sys
import math
cin = int(sys.stdin.readline().strip())
t = []
for i in range(cin):
	x = sys.stdin.readline().strip().split()
	t.append(x)
for i in t:
	for j in range(len(i)):
		i[j] = int(i[j])
for i in t:
	s = ''
	for j in range(i[0]):
		s = s + str(j + 1) + ' '
	s = s[:len(s) - 1]
	s = s + ' ' + s[0]
	print(s[2:])


T = int(input())
for t in range(T):
	n = int(input())
	a = [i for i in range(n + 1)]
	for i in range(1, n, 2):
		a[i + 1] = i
		a[i] = i + 1
	if n % 2 == 0:
		a = a[1:]
		print(*a)
	else:
		temp = a[-1]
		a[-1] = a[-2]
		a[-2] = temp
		a = a[1:]
		print(*a)


for _ in range(int(input())):
	n = int(input())
	l = [str(i) for i in range(1, n)]
	s = str(n) + ' ' + ' '.join(l)
	print(s)


def permutation(P):
	if P == 2:
		print('2 1')
	else:
		permIni = [*range(1, (P + 1) // 2)]
		permFim = [*range((P + 1) // 2, P + 1)]
		print(permFim[0], end='')
		for i in range(1, len(permFim)):
			print(' ' + str(permFim[i]), end='')
		for i in range(0, len(permIni)):
			print(' ' + str(permIni[i]), end='')
		print()
for i in range(int(input())):
	permutation(int(input()))


n = int(input())
for i in range(n):
	m = int(input())
	p = list(range(m, 0, -1))
	p = [str(i) for i in p]
	if m % 2 == 0:
		print(' '.join(p))
	else:
		temp = p[m // 2]
		p[m // 2] = p[-1]
		p[-1] = temp
		print(' '.join(p))


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


n = int(input())
l = []
p = []
for i in range(0, n):
	x = int(input())
	l.append(x)
	i += 1
q = len(l)
for j in range(0, q):
	for t in range(0, int(l[j])):
		p.append(l[j] - t)
	u = int((len(p) + 1) / 2)
	if len(p) % 2 != 0:
		p[0] = u
		p[u - 1] = len(p)
	for y in range(0, int(l[j])):
		print(p[y], end=' ')
	print('\n')
	p = []
	j += 1


a = int(input())
s = []
for i in range(99):
	s.append(str(i + 2))
for i in range(a):
	q = int(input())
	print(' '.join(s[:q - 1]) + ' 1')


for _ in range(int(input())):
	n = int(input())
	ans = [x for x in range(n, 0, -1)]
	mid = len(ans) // 2
	(ans[mid], ans[-1]) = (ans[-1], ans[mid])
	print(*ans)


for t in range(int(input())):
	n = int(input())
	l = [i + 1 for i in range(1, n + 1)]
	l[n - 1] = 1
	print(*l, sep=' ')


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


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


t = int(input())
if t:
	for i in range(t):
		n = int(input())
		if n:
			print(n, *range(1, n))


t = int(input())
lister = list()
lister2 = list()
for z in range(t):
	k = int(input())
	lister.append(k)
for z in range(t):
	m = list()
	m.extend(reversed(range(1, lister[z] + 1)))
	if lister[z] % 2 != 0:
		temp = m[lister[z] // 2]
		m[lister[z] // 2] = m[0]
		m[0] = temp
	for i in m:
		print(i, end=' ')
	print('')


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

def solve():
	[n] = read()
	a = []
	for i in range(1, n):
		a.append(i + 1)
	a.append(1)
	print(' '.join([str(i) for i in a]))

def main():
	[t] = read()
	for _ in range(t):
		solve()
	return 0
main()


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


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


import random
attemp = int(input())
while attemp != 0:
	attemp -= 1
	n = int(input())
	res = []
	for i in range(1, n):
		res.append(i + 1)
	res.append(1)
	for i in res:
		print(i, end=' ')
	print()


for _ in range(int(input())):
	n = int(input())
	print(' '.join((str(i) for i in range(2, n + 1))) + ' 1')


a = int(input())
for k in range(a):
	b = int(input())
	s = str(b) + ' '
	for i in range(1, b):
		s += str(i) + ' '
	print(s)


for _ in range(int(input())):
	t = int(input())
	temp = [i for i in range(1, t + 1)]
	temp = temp[::-1]
	if t % 2 == 0:
		print(*temp)
	else:
		print(*temp[:t // 2] + temp[t // 2 + 1:] + [temp[t // 2]])


for i in [*open(0)][1:]:
	print(*range(2, int(i) + 1), 1)


t = int(input())
for k in range(0, t):
	n = int(input())
	l = [str(n)]
	for j in range(1, n):
		l.append(str(j))
	print(' '.join(l))


from sys import stdin
input = stdin.readline
for Pythonic__Python in range(int(input())):
	n = int(input())
	for i in range(1, n + 1):
		if i == n:
			print(1)
		else:
			print(i + 1, end=' ')


for _ in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		print(*list(range(n, 0, -1)))
	else:
		a = list(range(n, 0, -1))
		a[n // 2] = 1
		a[n - 1] = n // 2 + 1
		print(*a)


for _ in range(int(input())):
	a = [x for x in range(int(input()), 0, -1)]
	mid = len(a) // 2
	(a[mid], a[-1]) = (a[-1], a[mid])
	print(*a)


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

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

def intip():
	return int(input())
for _ in range(intip()):
	n = intip()
	l = [i for i in range(1, n + 1)]
	l = l[::-1]
	mid = n // 2
	if n == 2:
		print(*l)
	elif n % 2 != 0:
		(l[mid], l[mid - 1]) = (l[mid - 1], l[mid])
		print(*l)
	else:
		(l[mid + 1], l[mid]) = (l[mid], l[mid + 1])
		print(*l)


def solve():
	n = int(input())
	print(str(n) + ' ', end=' ')
	for i in range(1, n):
		print(str(i) + ' ', end=' ')
	print()
t = int(input())
while t:
	solve()
	t -= 1


num = int(input())
for i in range(num):
	numz = int(input())
	arr = f'{numz} '
	for j in range(1, numz):
		if j != numz - 1:
			arr += f'{j} '
		else:
			arr += str(j)
	print(arr)


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


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	k = int(input())
	arr = []
	for i in range(k):
		arr.append(i + 1)
	if k % 2 == 0:
		arr.reverse()
		for a in arr:
			print(a, end=' ')
	else:
		arr.reverse()
		tmp = arr[k // 2]
		arr[k // 2] = arr[0]
		arr[0] = tmp
		for a in arr:
			print(a, end=' ')
	print()


from math import ceil
t = int(input())
while t > 0:
	n = int(input())
	result = [i for i in range(1, n + 1)]
	for i in range(0, n, 2):
		if i + 1 < n:
			(result[i], result[i + 1]) = (result[i + 1], result[i])
	if n % 2 != 0:
		(result[-1], result[-2]) = (result[-2], result[-1])
	print(' '.join(map(str, result)))
	t -= 1


n = int(input())
p = []
for i in range(0, n):
	l = int(input())
	p.append(l)
for i in p:
	s = ''
	for j in range(2, i + 1):
		s = s + f'{j}'
		s = s + ' '
	s = s + '1'
	print(s)


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


t = int(input())
x = []
for i in range(t):
	n = int(input())
	x.append(n)
for i in range(t):
	y = []
	if x[i] == 2:
		y.append(2)
		y.append(1)
		for j in range(2):
			print(y[j], end=' ')
		print()
	elif x[i] == 3:
		y.append(2)
		y.append(3)
		y.append(1)
		for j in range(3):
			print(y[j], end=' ')
		print()
	else:
		b = 3
		for j in range(x[i] - 2):
			y.append(b)
			b += 1
		y.append(1)
		y.append(2)
		for k in range(x[i]):
			print(y[k], end=' ')
		print()


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


n = int(input())
for _ in range(n):
	k = int(input())
	print(*[i % k + 1 for i in range(1, k + 1)])


for i in range(int(input())):
	y = []
	x = int(input())
	for i in range(1, x + 1):
		y.append(str(i + 1))
		if i == x:
			y.pop()
			y.append('1')
	print(' '.join(y))


t = int(input())
while t > 0:
	n = int(input())
	l = []
	for i in range(n):
		if i == 0:
			l.append(n)
		else:
			l.append(i)
	print(' '.join([str(j) for j in l]))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	lst = []
	for j in range(2, n + 1):
		lst.append(j)
	lst.append(1)
	print(' '.join((str(j) for j in lst)))


for _ in range(int(input())):
	n = int(input())
	seq = list(range(1, n + 1))
	print(*seq[1:] + [seq[0]])


a = input()
a = int(a)
b = a
while a:
	x = input()
	x = int(x)
	mylist = []
	z = int(x)
	while z:
		mylist.append(z)
		z -= 1
	if x % 2 != 0:
		y = int((x - 1) / 2)
		(mylist[y], mylist[y + 1]) = (mylist[y + 1], mylist[y])
	for i in mylist:
		print(i, end=' ')
	a -= 1


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

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

def si():
	return input()

def msi():
	return map(str, input().split())

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

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

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

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

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 998244353

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def main():
	for _ in range(ii()):
		n = ii()
		a = []
		for i in range(2, n + 1):
			a.append(i)
		a.append(1)
		print(*a)
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
from sys import stdout
from math import *
input = stdin.readline
for __ in range(int(input())):
	n = int(input())
	for i in range(2, n + 1):
		print(i, end=' ')
	print(1)


for s in range(int(input())):
	n = int(input())
	p = []
	for i in range(n, 0, -1):
		p.append(i)
	(p[n // 2], p[-1]) = (p[-1], p[n // 2])
	print(*p)


for i in range(int(input())):
	ans = ''
	a = int(input())
	for i in range(2, a + 1):
		ans += str(i) + ' '
	print(ans + ' ' + '1')


arr = []
for i in range(int(input())):
	arr.append(int(input()))
for n in arr:
	l = list(range(2, n + 1))
	l.append(1)
	print(*l)


t = int(input())
s = [2] * 100
for i in range(1, 101):
	if i & 1:
		s[i - 1] = i + 1
		continue
	s[i - 1] = i - 1
s = list(map(str, s))
for i in range(t):
	n = int(input())
	if n & 1:
		print(' '.join(s[0:n - 3]) + f' {n} {n - 2} {n - 1}')
		continue
	print(' '.join(s[0:n]))


a = int(input())
for i in range(a):
	n = int(input())
	x = 1
	for i in range(1, n + 1):
		if i < n:
			x = i + 1
		elif i == n:
			x = 1
		print(x, end=' ')


for _ in range(int(input())):
	n = int(input())
	l = []
	for i in range(n, 0, -1):
		l.append(i)
	if n % 2 != 0:
		a = l[n // 2]
		l[n // 2] = l[0]
		l[0] = a
	print(*l)


cases = int(input())
for i in range(cases):
	n = int(input())
	a = [i for i in range(1, n + 1)]
	dup = a + a
	jump = int((len(dup) - n) / 2)
	if n % 2 == 0:
		dup = dup[jump:len(dup) - jump]
	else:
		dup = dup[jump:len(dup) - jump - 1]
	for k in dup:
		print(k, end=' ')
	print('')


t = int(input())
while t:
	n = int(input())
	print(n, *list(range(1, n)))
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(2, n + 1):
		arr.append(i)
	arr.append(1)
	print(*arr)


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


n = int(input())
for i in range(n):
	number = int(input())
	ans = []
	for i in range(number, 0, -1):
		ans.append(i)
	if number % 2 != 0:
		index = number // 2
		temp = ans[index]
		ans[index] = ans[index + 1]
		ans[index + 1] = temp
	for i in range(len(ans)):
		print(ans[i], end=' ')
	print()


a = int(input())
for i in range(a):
	x = int(input())
	arr = [x for x in range(x, 0, -1)]
	if len(arr) % 2 != 0:
		temp = arr[len(arr) // 2]
		arr[len(arr) // 2] = arr[0]
		arr[0] = temp
	print(*arr)


count = int(input())
for _ in range(count):
	a = int(input())
	b = [str(i) for i in range(1, a + 1)]
	c = b.pop(-1)
	b.insert(0, c)
	c = ' '.join(b)
	print(c)


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


import math
t = int(input())
for turn in range(t):
	n = int(input())
	a = sorted([i for i in range(1, n + 1)], reverse=True)
	if len(a) > 2 and len(a) % 2 != 0:
		q = math.ceil(len(a) / 2)
		(a[0], a[q - 1]) = (a[q - 1], a[0])
	print(' '.join(map(str, a)))


for _ in range(int(input())):
	n = int(input())
	ans = list(range(n, 0, -1))
	if n % 2:
		(ans[-1], ans[n // 2]) = (ans[n // 2], ans[-1])
	print(' '.join(map(str, ans)))


def sol(n):
	p = [str(_) for _ in range(1, n + 1)]
	for _ in range(len(p)):
		if p[_] == str(_ + 1):
			t = p.pop(_)
			p.append(t)
	return ' '.join(p)
t = int(input())
for _ in range(t):
	n = int(input())
	print(sol(n))


t = int(input())
for i in range(0, t):
	m = int(input())
	arr = [m]
	for j in range(1, m):
		arr.append(j)
	print(*arr, sep=' ')


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


for i in range(int(input())):
	n = int(input())
	l = list(range(1, n + 1))
	l.pop(n - 1)
	print(n, *l)


for _ in range(int(input())):
	n = int(input())
	print(n, *range(1, n))


for i in range(int(input())):
	n = int(input())
	l = list(range(1, n + 1))
	if n % 2 == 0:
		l = l[::-1]
		print(*l)
	else:
		mid_element = n // 2
		a = l[mid_element]
		l.remove(l[mid_element])
		l = l[::-1]
		l.append(a)
		print(*l)


n = int(input())
l = []
for i in range(0, n):
	s = int(input())
	l.append(s)
for j in range(0, n):
	p = [0] * l[j]
	for k in range(0, l[j] - 1):
		p[k + 1] = k + 1
		p[0] = l[j]
	print(*p, ' ')


for _ in range(int(input())):
	n = int(input())
	temp = []
	temp.append(n)
	for i in range(1, n):
		temp.append(i)
	print(*temp)


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	while n > 0:
		a.append(n)
		n -= 1
	if len(a) % 2 == 0:
		print(' '.join(map(str, a)))
	else:
		a1 = a[len(a) // 2]
		a.remove(a1)
		a.append(a1)
		print(' '.join(map(str, a)))


t = int(input())
for q in range(t):
	n = int(input())
	ch = str(n) + ' '
	for i in range(1, n):
		ch += str(i) + ' '
	print(ch)


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = []
		for j in range(1, n + 1):
			if j == n:
				a.append(1)
			else:
				a.append(j + 1)
		print(*a)
main()


a = int(input())
c = []
for i in range(1, a + 1):
	b = int(input())
	c.append(b)
for x in c:
	print(2, *range(3, x + 1), 1)


t = int(input())
for z in range(t):
	n = int(input())
	if n % 2 == 0:
		for i in range(n, 0, -1):
			print(i)
	else:
		for j in range(n, 0, -1):
			if j == n // 2 + 1:
				print(n // 2)
			elif j == n // 2:
				print(n // 2 + 1)
			else:
				print(j)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import defaultdict as dd
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdmap = lambda : map(int, stdstr().split())
stdarr = lambda : list(map(int, stdstr().split()))
mod = 1000000007
for _ in range(stdint()):
	n = stdint()
	if n % 2 == 0:
		res = [i for i in range(1, n + 1)][::-1]
	else:
		m = (n + 1) // 2
		res = [m]
		for i in range(n, 0, -1):
			if i != m:
				res.append(i)
	print(*res)


import math, sys
from collections import defaultdict, Counter, deque
from functools import reduce
INF = float('inf')
MOD = int(1000000000.0) + 7

def solve():
	n = int(input())
	ans = [i for i in range(n, 0, -1)]
	if n % 2 == 1:
		mid = n // 2
		(ans[mid - 1], ans[mid]) = (ans[mid], ans[mid - 1])
	print(*ans)

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

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def sieve():
	MAX = int(1000000.0 + 1)
	primes = [1 for i in range(MAX)]
	primes[0] = primes[1] = 0
	i = 2
	while i <= MAX ** 0.5:
		j = i * i
		while primes[i] and j < MAX:
			if j % i == 0:
				primes[j] = 0
			j += i
		i += 1
	return primes

def input():
	return sys.stdin.readline().rstrip('\n').strip()

def print(*args, sep=' ', end='\n'):
	first = True
	for arg in args:
		if not first:
			sys.stdout.write(str(sep))
		sys.stdout.write(str(arg))
		first = False
	sys.stdout.write(end)

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

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


import math
t = int(input())

def func():
	n = int(input())
	seq = []
	for i in range(n, 0, -1):
		seq.append(i)
	if n % 2 == 1:
		mid_idx = math.ceil(n / 2) - 1
		aux = seq[mid_idx]
		seq[mid_idx] = seq[mid_idx + 1]
		seq[mid_idx + 1] = aux
	for i in seq:
		print(i, end=' ')
	print('')
for i in range(t):
	func()


t = int(input())
for t in range(t):
	p = int(input())
	lst = []
	if p % 2 != 0:
		q = p - 1
		lst.append(p // 2 + 1)
		for i in range(p):
			if i != lst[0] - 1:
				lst.append(q - i + 1)
	else:
		q = p
		for i in range(p):
			lst.append(q - i)
	print(*lst)


t = int(input())
for r in range(t):
	n = int(input())
	l = []
	for i in range(1, n + 1):
		l.append(i)
	for i in range(n - 1):
		p = l[i]
		l[i] = l[i + 1]
		l[i + 1] = p
	for i in l:
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline

def prog():
	for _ in range(int(input())):
		n = int(input())
		a = [n]
		for i in range(1, n):
			a.append(i)
		print(*a)
prog()


for i in range(int(input())):
	n = int(input())
	print(n, *range(1, n))


for i in range(int(input())):
	n = int(input())
	arr = [str(i) for i in range(n, 0, -1)]
	if n % 2 != 0:
		temp = arr[n // 2 + 1]
		arr[n // 2 + 1] = arr[n // 2]
		arr[n // 2] = temp
	print(' '.join(arr))


def function(x):
	a = [0] * x
	for i in range(x):
		if i == x - 1:
			a[i] = 1
		else:
			a[i] = i + 2
	return a
n = int(input())
for i in range(n):
	b = int(input())
	b = function(b)
	print(' '.join(map(str, b)))


for i in range(int(input())):
	n = int(input())
	x = []
	for i in range(2, n + 1):
		x.append(i)
	x.append(1)
	print(*x)


a = []
k = int(input())
b = [[] for i in range(k)]
for i in range(k):
	n = int(input())
	a = [i for i in range(1, n + 1)]
	if len(a) % 2 == 0:
		for x in range(int(n / 2)):
			(a[x], a[n - 1 - x]) = (a[n - 1 - x], a[x])
	else:
		for x in range(int(n / 2)):
			(a[x], a[n - 1 - x]) = (a[n - 1 - x], a[x])
		(a[int(n / 2)], a[0]) = (a[0], a[int(n / 2)])
	b[i] = a
for i in range(k):
	print(*b[i], sep=' ')


n = int(input())
array = []
for i in range(n):
	x = int(input())
	arr = [0] * x
	for j in range(1, x):
		arr[j] = j
	arr[0] = x
	print(*arr)


import math
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(1, n + 1):
		a.append(i)
	a.reverse()
	if n % 2 == 0:
		print(*a)
	else:
		t = a[n // 2]
		a[n // 2] = a[n - 1]
		a[n - 1] = t
		print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	print(n, *list(range(1, n)))


import random
t = int(input())
while t:
	n = int(input())
	res = [n]
	for i in range(1, n):
		res.append(i)
	print(' '.join(map(str, res)))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	permutation = list(range(2, n + 2))
	permutation[-1] = 1
	permutation = list(map(str, permutation))
	print(' '.join(permutation))


for _ in range(int(input())):
	n = int(input())
	res = [n]
	for i in range(1, n):
		res.append(i)
	print(*res)


for _ in range(int(input())):
	n = int(input())
	p = [i + 1 for i in range(n - 1)]
	p = [n] + p
	print(*p)


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


N = int(input())
for _ in range(N):
	n = int(input())
	a = []
	for i in range(0, n):
		a.insert(0, i + 1)
	if n % 2 == 1:
		a[0] = a[n // 2]
		a[n // 2] = n
	print(*a)


def solve():
	n = int(input())
	if n % 2 == 0:
		for i in range(n):
			print(str(n - i), end=' ')
		print('')
	else:
		mid = int(n / 2)
		for i in range(n):
			if i == mid:
				print(str(1), end=' ')
			elif i == n - 1:
				print(str(mid + 1), end=' ')
			else:
				print(str(n - i), end=' ')
		print('')
t = int(input())
for i in range(t):
	solve()


for i in range(int(input())):
	n = int(input())
	output = ''
	if n % 2 == 0:
		for i in range(n, 0, -1):
			output += str(i) + ' '
	else:
		for i in range(2, n + 1):
			output += str(i) + ' '
		output += '1'
	print(output)


a = int(input())
for i in range(a):
	b = int(input())
	c = []
	d = 0
	if b == 3:
		print(2, 3, 1)
	else:
		if b % 2 == 0:
			for j in range(b, 0, -1):
				c.append(j)
		else:
			for e in range(b, b // 2 + 1, -1):
				c.append(e)
				if e == b // 2 + 2:
					for w in range(1, b // 2 + 2):
						c.append(w)
		print(*c)


t = int(input())
for testcase in range(t):
	n = int(input())
	perm = [i for i in range(1, n + 1)]
	perm.pop()
	perm = [n] + perm
	print(' '.join([str(i) for i in perm]))


for _ in range(int(input())):
	n = int(input())
	if n == 2:
		print(2, 1)
	else:
		l1 = [x for x in range(3, n + 1)] + [1] + [2]
		for i in l1:
			print(i, end=' ')
		print()


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	arr = []
	n = int(input())
	for i in range(n, 0, -1):
		arr.append(i)
	if n % 2:
		(arr[-1], arr[n // 2]) = (arr[n // 2], arr[-1])
	print(*arr)
	t -= 1


t = int(input())

def solve(n):
	lst = [n]
	for i in range(n - 1):
		lst.append(i + 1)
	print(' '.join(map(str, lst)))
for i in range(t):
	n = int(input())
	solve(n)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(range(n, 0, -1))
	if n % 2:
		tmp = a[n // 2]
		a[n // 2] = a[n // 2 - 1]
		a[n // 2 - 1] = tmp
	print(*a)


t = int(input())
for _ in range(0, t):
	n = int(input())
	print(*[1 + (i + 1) % n for i in range(0, n)])


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