There are $n$ cats in a line, labeled from $1$ to $n$, with the $i$-th cat at position $i$. They are bored of gyrating in the same spot all day, so they want to reorder themselves such that no cat is in the same place as before. They are also lazy, so they want to minimize the total distance they move. Help them decide what cat should be at each location after the reordering.

For example, if there are $3$ cats, this is a valid reordering: $[3, 1, 2]$. No cat is in its original position. The total distance the cats move is $1 + 1 + 2 = 4$ as cat $1$ moves one place to the right, cat $2$ moves one place to the right, and cat $3$ moves two places to the left.


-----Input-----

The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases. Then $t$ test cases follow.

The first and only line of each test case contains one integer $n$ ($2 \leq n \leq 100$) — the number of cats.

It can be proven that under the constraints of the problem, an answer always exist.


-----Output-----

Output $t$ answers, one for each test case. Each answer consists of $n$ integers — a permutation with the minimum total distance. If there are multiple answers, print any.


-----Examples-----

Input
2
2
3
Output
2 1 
3 1 2


-----Note-----

For the first test case, there is only one possible permutation that satisfies the conditions: $[2, 1]$.

The second test case was described in the statement. Another possible answer is $[2, 3, 1]$.

Difficulty: EASY
Tags: Greedy algorithms

Implementation

Constructive algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
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: 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=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

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

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

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

	def __len__(self):
		return self._len

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

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

class 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

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	n = int(input())
	ans = [i for i in range(1, n + 1)]
	for i in range(1, n, 2):
		(ans[i], ans[i - 1]) = (ans[i - 1], ans[i])
	if n % 2 == 1:
		(ans[-1], ans[-2]) = (ans[-2], ans[-1])
	print(*ans)


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


import sys

def str_arr(arr):
	return ' '.join(map(str, arr))

def solve(n):
	answer = [i + 1 for i in range(n)]
	start = 0
	if n % 2 == 1:
		answer[:3] = [3, 1, 2]
		start = 3
	for j in range(start, n - 1, 2):
		(answer[j], answer[j + 1]) = (answer[j + 1], answer[j])
	return str_arr(answer)

def main():
	outputs = []
	fin = sys.stdin
	N = int(fin.readline())
	for _ in range(N):
		n = int(fin.readline())
		outputs.append(solve(n))
	print('\n'.join(map(str, outputs)))
main()


def binpow(a, b, m):
	a %= m
	x = 1
	while b > 0:
		if b & 1:
			x = x * a % m
		a = a * a % m
		b >>= 1
	return x

def sieve(n):
	d = defaultdict(list)
	if n < 9:
		n = 10
	l = [1] * n
	for i in range(2, int(n ** 0.5) + 1):
		if l[i - 1] == 1:
			for j in range(i ** 2, n + 1, i):
				if j % i == 0:
					l[j - 1] = 0
					d[j].append(i)
	return (l, d)

def binser(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return mid

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

def panda(n):
	l = [k for k in range(1, n + 1)]
	for i in range(0, n - n % 2, 2):
		(l[i], l[i + 1]) = (l[i + 1], l[i])
	if n % 2:
		(l[-1], l[-2]) = (l[-2], l[-1])
	return l

def main():
	t = int(input())
	for _ in range(t):
		print(*panda(int(input())))
from math import *
from collections import *
import os
from io import BytesIO, IOBase
import sys, threading
import bisect
import itertools
from sys import stdout
MOD = 1000000007
N = 1000000007
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


t = int(input())
for i in range(t):
	n = int(input())
	l = [i for i in range(1, n + 1)]
	for i in range(0, n - 1, 2):
		(l[i], l[i + 1]) = (l[i + 1], l[i])
	if n % 2 != 0:
		(l[n - 1], l[n - 2]) = (l[n - 2], l[n - 1])
	for i in l:
		print(i, end=' ')
	print()


for ii in range(int(input())):
	n = int(input())
	i = n % 2 + 3
	print(2, n % 2 * '3', 1)
	while i < n:
		print(i + 1, i)
		i += 2


c = int(input())
for _ in range(c):
	l = []
	n = int(input().strip())
	if n % 2 == 0:
		for i in range(1, n + 1):
			if i % 2 == 0:
				l.append(str(i - 1))
			else:
				l.append(str(i + 1))
	else:
		l.extend(['3', '1', '2'])
		for i in range(1, n + 1):
			if i < 4:
				continue
			if i % 2 != 0:
				l.append(str(i - 1))
			else:
				l.append(str(i + 1))
	print(' '.join(l))


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


import sys
from collections import deque
input = sys.stdin.readline
output = sys.stdout.write

def main():
	tests = int(input())
	for i in range(tests):
		d = deque()
		num = int(input())
		for j in range(1, num + 1):
			if j % 2 == 1:
				d.append(j + 1)
			else:
				d.append(j - 1)
		if num % 2 == 1:
			d[-2] += 2
			d[-1] -= 3
		for e in d:
			output(str(e) + ' ')
		output('\n')
main()


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


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		cat = [i for i in range(1, n + 1)]
		if len(cat) % 2 > 0:
			(cat[0], cat[1], cat[2]) = (cat[2], cat[0], cat[1])
			if len(cat) > 3:
				for i in range(3, len(cat) - 1, 2):
					(cat[i], cat[i + 1]) = (cat[i + 1], cat[i])
		else:
			for i in range(0, n - 1, 2):
				(cat[i], cat[i + 1]) = (cat[i + 1], cat[i])
		print(*cat)
main()


def solve(n):
	res = []
	if n % 2 == 0:
		for i in range(n // 2):
			res.append(str(2 * i + 2))
			res.append(str(2 * i + 1))
	else:
		for i in range((n - 3) // 2):
			res.append(str(2 * i + 2))
			res.append(str(2 * i + 1))
		res.append(str(n))
		res.append(str(n - 2))
		res.append(str(n - 1))
	return ' '.join(res)
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input().decode().strip())
for i in range(T):
	n = int(input().decode().strip())
	res = solve(n)
	print(res)


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


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


t1 = int(input())
for hi in range(t1):
	n = int(input())
	t = ''
	if n % 2 == 0:
		for i in range(1, n + 1):
			if i % 2 == 1:
				t += str(i + 1) + ' '
			else:
				t += str(i - 1) + ' '
		print(t[:-1])
	else:
		t = '3 1 2 '
		for i in range(4, n + 1):
			if i % 2 == 0:
				t += str(i + 1) + ' '
			else:
				t += str(i - 1) + ' '
		print(t[:-1])


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


a = int(input())
for i in range(a):
	n = int(input())
	n1 = []
	o = []
	for j in range(n):
		n1.append(j + 1)
	if n % 2 == 0:
		for j in range(len(n1) // 2):
			a = n1[0]
			b = n1[1]
			o.append(b)
			o.append(a)
			n1 = n1[2:]
	else:
		n2 = n1[:len(n1) - 3]
		n3 = n1[-3:]
		for j in range(len(n2) // 2):
			a = n2[0]
			b = n2[1]
			o.append(b)
			o.append(a)
			n2 = n2[2:]
		a = n3[0]
		b = n3[1]
		c = n3[2]
		o.append(c)
		o.append(a)
		o.append(b)
	for j in range(len(o)):
		print(o[j], end=' ')
	print()


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


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


import sys
import math
import os.path
from collections import *
from queue import *
from bisect import *
from heapq import *
MOD = int(1000000000.0 + 7)
inf = float('inf')
ninf = float('-inf')
input = sys.stdin.buffer.readline

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

def deb(a, b='Debugging'):
	print(b, *a) if os.path.exists('inp.txt') else ''
for _ in range(int(input())):
	(n,) = ii()
	if n % 2 == 0:
		for k in range(1, n, 2):
			print(k + 1, k, end=' ')
		print()
	else:
		for k in range(1, n - 2, 2):
			print(k + 1, k, end=' ')
		print(n, n - 2, n - 1)


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


def pretty(n):
	if n % 2 == 0:
		r = []
		for i in range(n):
			if i % 2 == 0:
				r.append(i + 2)
			else:
				r.append(i)
	else:
		r = [3, 1, 2]
		for i in range(3, n):
			if i % 2 == 0:
				r.append(i)
			else:
				r.append(i + 2)
	return r
for i in range(int(input())):
	n = int(input())
	print(*pretty(n))


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


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


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


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


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


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


num = int(input())
for i in range(num):
	lenz = int(input())
	ans = []
	if lenz % 2 == 0:
		for j in range(0, lenz, 2):
			ans.append(str(j + 2))
			ans.append(str(j + 1))
	else:
		ans = ['3', '1', '2']
		for j in range(4, lenz, 2):
			ans.append(str(j + 1))
			ans.append(str(j))
	print(' '.join(ans))


for _ in range(int(input())):
	n = int(input())
	ans = []
	ans.append(n)
	for i in range(1, n):
		ans.append(i)
	if n == 1:
		ans = [1]
		print(*ans)
	elif n == 2:
		ans = [2, 1]
		print(*ans)
	elif n == 3:
		ans = [3, 1, 2]
		print(*ans)
	else:
		even = [2, 1]
		odd = [3, 1, 2]
		if n % 2 == 0:
			ans = even
			x = 2
			for i in range(0, n - 2):
				if i % 2 == 0:
					ans.append(x + 2)
				if i % 2 != 0:
					ans.append(x + 1)
					x += 2
			print(*ans)
		else:
			ans = odd
			x = 3
			for i in range(0, n - 3):
				if i % 2 == 0:
					ans.append(x + 2)
				if i % 2 != 0:
					ans.append(x + 1)
					x += 2
			print(*ans)


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


from itertools import permutations
t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	if n % 2 == 0:
		for i in range(1, n + 1):
			if i % 2 != 0:
				a.append(i + 1)
			else:
				a.append(i - 1)
	else:
		for i in range(1, n):
			if i % 2 != 0:
				a.append(i + 1)
			elif i % 2 == 0:
				a.append(i - 1)
		a.append(n)
		(a[n - 2], a[n - 1]) = (a[n - 1], a[n - 2])
	print(*a)


m = int(input())
for _ in range(m):
	n = int(input())
	b = [3, 1, 2]
	if n % 2 == 0:
		a = [x + 1 if x % 2 != 0 else x - 1 for x in range(1, n + 1)]
		print(*a, sep=' ')
	elif n > 3:
		a = [x - 1 if x % 2 != 0 else x + 1 for x in range(4, n + 1)]
		print(*b + a, sep=' ')
	else:
		print(*b, sep=' ')


l = []
l2 = []
n = int(input())
for i in range(1, n + 1):
	x = int(input())
	for j in range(1, x + 1):
		l.append(j)
	if x == 1:
		print(1)
	elif x % 2 == 0:
		for j in range(0, x):
			if j % 2 == 0 and j < x:
				l2.insert(j, l[j + 1])
				l2.insert(j + 1, l[j])
		for j in range(0, x):
			print(l2[j], end=' ')
	else:
		for j in range(0, x - 1):
			if j % 2 == 0 and j < x - 1:
				l2.insert(j, l[j + 1])
				l2.insert(j + 1, l[j])
		l2.insert(x - 1, l[x - 1])
		for j in range(0, x):
			if j == x - 1:
				print(l2[j - 2], end=' ')
			elif j == x - 3:
				print(l2[j + 2], end=' ')
			else:
				print(l2[j], end=' ')
	print()
	l = []
	l2 = []


import sys
import math
from collections import deque, Counter
sys.setrecursionlimit(10 ** 7)
int1 = lambda x: int(x) - 1
mi = lambda : map(int, input().split())
li = lambda : list(mi())
mi1 = lambda : map(int1, input().split())
li1 = lambda : list(mi1())
mod = 10 ** 9 + 7
Mod = 998244353
INF = 10 ** 18
ans = 0
t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2 == 0:
		a = []
		for i in range(n):
			if i % 2 == 0:
				a.append(i + 2)
			else:
				a.append(i)
		print(*a)
	else:
		a = []
		for i in range(n - 3):
			if i % 2 == 0:
				a.append(i + 2)
			else:
				a.append(i)
		a.append(n)
		a.append(n - 2)
		a.append(n - 1)
		print(*a)


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


t = int(input())
for _ in range(t):
	n = int(input())
	arr = []
	if n % 2 == 0:
		i = 1
		while i < n:
			arr.append(i + 1)
			arr.append(i)
			i += 2
	else:
		i = 4
		arr = [2, 3, 1]
		while i < n:
			arr.append(i + 1)
			arr.append(i)
			i += 2
	print(*arr)


import math, sys, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in wtf[1:]:
	n = int(t)
	A = [i for i in range(1, n + 1)]
	for i in range(0, n - 1, 2):
		(A[i], A[i + 1]) = (A[i + 1], A[i])
	if n % 2 > 0:
		(A[n - 2], A[n - 1]) = (A[n - 1], A[n - 2])
	print(' '.join(map(str, A)))


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


t = int(input())
for i in range(t):
	x = int(input())
	arr = []
	i = 0
	if x % 2 == 0:
		arr = [x for x in range(1, x + 1)]
		while i < x:
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			i += 2
	else:
		arr = [x for x in range(1, x + 1)]
		while i < x - 1:
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
			i += 2
		(arr[len(arr) - 1], arr[len(arr) - 2]) = (arr[len(arr) - 2], arr[len(arr) - 1])
	print(*arr)


t = int(input())
natija = []
for i in range(t):
	n = int(input())
	S = ''
	if n == 3:
		S = '3 1 2'
	elif n % 2 == 0:
		for i in range(1, n // 2 + 1):
			S += str(2 * i) + ' ' + str(2 * i - 1) + ' '
	else:
		for i in range(1, n // 2):
			S += str(2 * i) + ' ' + str(2 * i - 1) + ' '
		S += str(n) + ' ' + str(n - 2) + ' ' + str(n - 1)
	natija.append(S.strip())
for i in range(t):
	print(natija[i])


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


n = int(input())
for i in range(n):
	w = int(input())
	l = [int(x) for x in range(1, w + 1)]
	if w % 2 == 0:
		for i in range(0, w - 1, 2):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
	elif w < 5:
		for i in range(w - 1):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
	elif w >= 5 and w % 2 != 0:
		for i in range(3, w - 1, 2):
			(l[i], l[i + 1]) = (l[i + 1], l[i])
		l.pop(2)
		l.insert(0, 3)
	print(*l, sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2:
		print('3 1 2', *[i + 1 if i % 2 == 0 else i - 1 for i in range(4, n + 1)], sep=' ')
	else:
		print(*[j + 1 if j % 2 != 0 else j - 1 for j in range(1, n + 1)], sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = list((i for i in range(1, n + 1)))
	i = 0
	while i < len(a) and i < len(a) - 1:
		(a[i], a[i + 1]) = (a[i + 1], a[i])
		i += 2
	if len(a) % 2:
		(a[len(a) - 1], a[len(a) - 2]) = (a[len(a) - 2], a[len(a) - 1])
	for i in a:
		print(i, end=' ')
	print()


for s in [*open(0)][1:]:
	n = int(s)
	for i in range(0, n - n % 2 * 3, 2):
		print(i + 2, i + 1)
	if n % 2:
		print(n, n - 2, n - 1)


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


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

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

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

def read_int():
	return int(input())

def ans(x):
	ret = list(range(1, x + 1))
	if len(ret) % 2 == 0:
		for i in range(len(ret)):
			if i % 2 == 0:
				(ret[i], ret[i + 1]) = (ret[i + 1], ret[i])
	else:
		for i in range(3, len(ret)):
			if i % 2 == 1:
				(ret[i], ret[i + 1]) = (ret[i + 1], ret[i])
		ret[0] = 3
		ret[1] = 1
		ret[2] = 2
	return ' '.join(map(str, ret))
for _ in range(read_int()):
	print(ans(read_int()))


def lv_prasad(a):
	a += 1
for _ in range(int(input())):
	n = int(input())
	l = [x for x in range(1, n + 1)]
	c = n
	c = n - 1 if n % 2 != 0 else n
	for j in range(0, c, 2):
		(l[j], l[j + 1]) = (l[j + 1], l[j])
	if n % 2 == 0:
		print(*l)
	else:
		(l[n - 1], l[n - 2]) = (l[n - 2], l[n - 1])
		print(*l)


from sys import stdin, exit, setrecursionlimit
setrecursionlimit(100000000)
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	n = int(input())
	arr = [i for i in range(1, n + 1)]
	for i in range(0, n - 1, 2):
		(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
	if n % 2 == 1:
		(arr[-3], arr[-2], arr[-1]) = (arr[-1], arr[-2], arr[-3])
	print(*arr)


for _ in range(int(input())):
	n = int(input())
	if n % 2:
		a = [3, 1, 2]
		for x in range(4, n + 1, 2):
			a.extend([x + 1, x])
	else:
		a = []
		for x in range(1, n + 1, 2):
			a.extend([x + 1, x])
	print(' '.join(map(str, a)))


for _ in range(int(input())):
	f = int(input())
	a = list(range(1, f + 1))
	b = []
	for i in a:
		if i % 2 != 0:
			b.append(i + 1)
		else:
			b.append(i - 1)
	if len(a) % 2 != 0:
		b[-1] = f
		(b[-1], b[-2]) = (b[-2], b[-1])
	print(*b)


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


t = int(input())
for i in range(t):
	n = int(input())
	otv = ''
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				otv += str(i + 2) + ' '
			else:
				otv += str(i) + ' '
	else:
		otv += '3 1 2 '
		for i in range(n - 3):
			if i % 2 == 0:
				otv += str(i + 5) + ' '
			else:
				otv += str(i + 3) + ' '
	print(otv[:len(otv) - 1])


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


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


t = int(input())
for _ in range(t):
	n = int(input())
	l = []
	r = []
	if n % 2 == 0:
		if n == 2:
			print(2, 1, end=' ')
		else:
			print(2, 1, end=' ')
			for i in range(3, n + 1):
				if i % 2 == 0:
					print(i - 1, end=' ')
				else:
					print(i + 1, end=' ')
	elif n == 3:
		print(3, 1, 2, end=' ')
	else:
		print(3, 1, 2, end=' ')
		for i in range(4, n + 1):
			if i % 2 == 0:
				print(i + 1, end=' ')
			else:
				print(i - 1, end=' ')
	print()


import time
from queue import Queue
from itertools import accumulate
from io import BytesIO, IOBase
from itertools import combinations
import threading
from collections import deque
from functools import reduce, cmp_to_key
import sys
from math import sqrt
import heapq
import random
import math
from collections import defaultdict
from collections import Counter
import io
import os
import bisect
from fractions import Fraction

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

def iinput():
	return int(input())

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

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def swap(arr, a, b):
	(arr[a], arr[b]) = (arr[b], arr[a])
n = iinput()
for _ in range(n):
	v = iinput()
	ans = []
	for i in range(1, v // 2 * 2 + 1, 2):
		ans.append(i + 1)
		ans.append(i)
	if v % 2:
		ans.append(v)
	if v >= 3 and v % 2:
		(ans[-1], ans[-3]) = (ans[-3], ans[-1])
	print(*ans)


answers = []

def solve(n):
	store = [i for i in range(1, n + 1)]
	if n % 2 == 0:
		for i in range(0, n - 1, 2):
			(store[i], store[i + 1]) = (store[i + 1], store[i])
		answers.append(store)
	else:
		for i in range(0, n - 1, 2):
			(store[i], store[i + 1]) = (store[i + 1], store[i])
		(store[-1], store[-2]) = (store[-2], store[-1])
		answers.append(store)
T = int(input())
while T:
	n = int(input())
	solve(n)
	T -= 1
for ans in answers:
	print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = []
	for i in range(1, n + 1):
		x.append(i)
	for j in range(0, n - 1, 2):
		(x[j], x[j + 1]) = (x[j + 1], x[j])
	if len(x) % 2 != 0:
		(x[-1], x[-2]) = (x[-2], x[-1])
	print(*x)


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


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = []
	for i in range(1, n + 1):
		a.append(i)
	if n % 2 == 0:
		for i in range(0, n, 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		print(*a, sep=' ')
	elif n == 3:
		print('3 1 2')
	else:
		y = n - 3
		for i in range(0, y, 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		for i in range(3):
			a.pop()
		a.append(n)
		a.append(n - 2)
		a.append(n - 1)
		print(*a, sep=' ')


import os
import sys
from io import BytesIO, IOBase
from math import ceil, floor, pow, sqrt, gcd
from collections import Counter, defaultdict
from itertools import permutations, combinations
from time import time, sleep
BUFSIZE = 8192
MOD = 1000000007

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')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from os import path
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

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

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

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

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

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

def gs():
	return stdin.readline().strip()

def gls():
	return list(stdin.readline().strip())

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

def pri(i, end='\n'):
	stdout.write(f'{i}' + end)

def priar(ar, end='\n'):
	stdout.write(' '.join(map(str, ar)) + end)

def solve():
	n = gi()
	ans = []
	if n % 2 == 0:
		for i in range(1, n, 2):
			ans.append(i + 1)
			ans.append(i)
	else:
		i = -1
		for i in range(1, n - 3, 2):
			ans.append(i + 1)
			ans.append(i)
		ans.append(i + 4)
		ans.append(i + 2)
		ans.append(i + 3)
	return ans
tc = gi()
for i in range(tc):
	priar(solve())


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


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


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


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


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


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		if n & 1 == 0:
			for i in range(1, n + 1, 2):
				print(i + 1, i, sep=' ', end=' ')
			print()
		else:
			for i in range(1, n - 2, 2):
				print(i + 1, i, sep=' ', end=' ')
			print(n, n - 2, n - 1, sep=' ')
main()


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


import math

def Solve():
	n = int(input())
	a = []
	for i in range(n):
		a.append(i + 1)
	if n % 2 == 0:
		for i in range(0, len(a), 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
	else:
		for i in range(0, len(a) - 1, 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		(a[-1], a[-2]) = (a[-2], a[-1])
	for x in a:
		print(x, end=' ')
	print()
q = int(input())
while q > 0:
	Solve()
	q -= 1


from itertools import combinations_with_replacement
import sys
from sys import stdin
import math
import bisect

def BinarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def iinput():
	return int(input())

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

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

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

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

def flinput():
	return list(map(int, stdin.readline().strip().split()))
for _ in range(iinput()):
	n = iinput()
	ll = []
	if n == 3:
		print('3 1 2')
	elif n % 2 == 0:
		for i in range(0, n, 2):
			ll.append(i + 1 + 1)
			ll.append(i + 1)
		print(*ll)
	else:
		for i in range(0, n - 3, 2):
			ll.append(i + 1 + 1)
			ll.append(i + 1)
		i = i + 2
		ll.append(i + 1 + 2)
		ll.append(i + 1)
		ll.append(i + 1 + 1)
		print(*ll)


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


n = int(input())
for i in range(n):
	number = int(input())
	cats = list(range(1, number + 1))
	if number % 2 == 0:
		for cat in cats:
			if cat % 2 != 0:
				cats[cat - 1] += 1
			else:
				cats[cat - 1] -= 1
	else:
		for cat1 in cats[:-3]:
			if cat1 % 2 != 0:
				cats[cat1 - 1] += 1
			else:
				cats[cat1 - 1] -= 1
		cats[-3] += 2
		cats[-2] -= 1
		cats[-1] -= 1
	print(*cats)


t = int(input())
while t:
	n = int(input())
	i = 1
	if n % 2 == 0:
		while i <= n // 2:
			print(i * 2, i * 2 - 1, end=' ')
			i = i + 1
	else:
		while i < n // 2:
			print(i * 2, i * 2 - 1, end=' ')
			i = i + 1
		print(i * 2, n, end=' ')
		print(i * 2 - 1)
	t = t - 1


tests = int(input())
for _ in range(tests):
	m = int(input())
	res = [i + 1 for i in range(m)]
	if m % 2:
		res[:3] = [3, 1, 2]
		b = 3
	else:
		b = 0
	for i in range(b, m - 1, 2):
		(res[i], res[i + 1]) = (res[i + 1], res[i])
	for r in res:
		print(r, end=' ')
	print()


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


import sys
sys.stdin.readline()
for l in sys.stdin:
	x = int(l.strip())
	add = 1
	if x == 1:
		print('1')
		continue
	if x % 2 == 1:
		add = 4
		x -= 3
		print('3 1 2', end=' ')
	for i in range(x):
		print(i // 2 * 2 + 1 - i % 2 + add, end=' ')
	print()


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	ans = []
	if n % 2 == 1:
		ans = [3, 1, 2]
		for i in range(4, n, 2):
			ans.append(i + 1)
			ans.append(i)
		print(*ans)
		continue
	for i in range(1, n, 2):
		ans.append(i + 1)
		ans.append(i)
	print(*ans)


n = int(input())
for i in range(n):
	m = int(input())
	l = list()
	for j in range(1, m + 1, 2):
		l.append(str(j + 1))
		l.append(str(j))
	if m % 2 != 0:
		(l[-1], l[-2], l[-3]) = (l[-2], l[-3], l[-1])
		print(' '.join(l[:-1]))
	else:
		print(' '.join(l))


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


for g in [*open(0)][1:]:
	g = int(g)
	b = (g - 2) // 2
	for i in range(1, b + 1):
		print(i * 2, end=' ')
		print(i * 2 - 1, end=' ')
	if g % 2:
		print(g, g - 2, g - 1)
	else:
		print(g, g - 1)


n = int(input())
for i in range(n):
	m = int(input())
	l1 = []
	for j in range(1, m + 1):
		l1.append(j)
	k = 0
	while k < m - 1:
		(l1[k], l1[k + 1]) = (l1[k + 1], l1[k])
		k += 2
	if m % 2 == 0:
		print(*l1)
	else:
		a = l1[-2]
		b = l1[-1]
		l1[-1] = a
		l1[-2] = b
		print(*l1)


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


for i in [*open(0)][1:]:
	i = int(i)
	if i % 2:
		print('3 1 2 ', end='')
	for j in range(4 - 3 * (i % 2 == 0), i, 2):
		print(j + 1, j, end=' ')
	print()


t = int(input())
for ll in range(t):
	n = int(input())
	ans = [i for i in range(1, n + 1)]
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
	else:
		for i in range(n):
			if i % 2 == 0 and i != n - 1:
				(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
			elif i == n - 1:
				(ans[i], ans[i - 1]) = (ans[i - 1], ans[i])
	for i in range(len(ans)):
		print(ans[i], end=' ')


for _ in range(int(input())):
	n = int(input())
	ans = []
	i = 1
	if n % 2 == 1:
		ans = [3, 1, 2]
		i = 4
		while i < n:
			ans.append(i + 1)
			ans.append(i)
			i += 2
	else:
		while i < n:
			ans.append(i + 1)
			ans.append(i)
			i += 2
	print(*ans)


t = int(input())

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


T = int(input())
count = 0
while count < T:
	x = int(input())
	if x % 2 == 0:
		for i in range(1, x + 1, 2):
			print(i + 1, i, end=' ')
	else:
		print(3, 1, 2, end=' ')
		for i in range(4, x + 1, 2):
			print(i + 1, i, end=' ')
	print()
	count += 1


def solve(t_id):
	n = int(input())
	ans = []
	if n % 2 == 0:
		ans = [2, 1]
	else:
		ans = [3, 1, 2]
	for i in range(3 + n % 2, n + 1, 2):
		ans.append(i + 1)
		ans.append(i)
	print(*ans)
t = 1
t = int(input())
for i in range(t):
	solve(i + 1)


s = int(input())
for _ in range(s):
	n = int(input())
	p = []
	for i in range(1, n + 1):
		p.append(i)
	for i in range(0, len(p) - 1, 2):
		(p[i], p[i + 1]) = (p[i + 1], p[i])
	if len(p) % 2 == 0:
		print(*p)
	else:
		(p[-1], p[-2]) = (p[-2], p[-1])
		print(*p)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(range(1, n + 1))
	if n % 2 == 0:
		for j in range(0, n, 2):
			a = l[j]
			l[j] = l[j + 1]
			l[j + 1] = a
	else:
		for j in range(0, n - 4, 2):
			a = l[j]
			l[j] = l[j + 1]
			l[j + 1] = a
		m = n - 3
		a = l[m]
		b = l[m + 1]
		l[m] = l[m + 2]
		l[m + 1] = a
		l[m + 2] = b
	s = str(l)
	s.strip('[]')
	while s.find(',') != -1:
		x = s.find(',')
		s = s[:x] + s[x + 1:]
	s = s[1:len(s) - 1]
	print(s)


t = input()
t = int(t)
for i in range(0, t):
	n = input()
	n = int(n)
	lst = []
	for i in range(0, n - 1, 2):
		lst.append(i + 2)
		lst.append(i + 1)
	if n % 2 == 1:
		ele = lst[-1]
		lst.pop()
		lst.append(n)
		lst.append(ele)
	for item in lst:
		print(item, end=' ')


for _ in range(int(input())):
	n = int(input())
	li = []
	(x1, x2, flag) = (1, 2, 0)
	for i in range(n):
		if flag == 0:
			li.append(x2)
			x2 += 2
			flag = 1
		else:
			li.append(x1)
			x1 += 2
			flag = 0
	if n & 1 == 0:
		print(*li)
	else:
		li[n - 1] = x2 - 3
		(li[n - 3], li[n - 1]) = (li[n - 1], li[n - 3])
		print(*li)


for _ in range(int(input())):
	n = int(input())
	l = [i for i in range(1, n + 1)]
	if n % 2 == 0:
		print('2', '1', end='')
		for i in range(2, len(l) - 1, 2):
			print('', l[i + 1], l[i], end='')
	else:
		print('3 1 2', end='')
		for i in range(3, len(l) - 1, 2):
			print('', l[i + 1], l[i], end='')
	print('\n')


for s in [*open(0)][1:]:
	n = int(s)
	i = n % 2 + 3
	print(2, *n % 2 * [3], 1)
	while i <= n:
		print(i + 1, i)
		i += 2


import sys
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = inp()
for i in range(t):
	n = inp()
	a = [i for i in range(1, n + 1)]
	for i in range(1, n, 2):
		(a[i], a[i - 1]) = (a[i - 1], a[i])
	if n % 2:
		a[n - 3] = n
		a[n - 2] = n - 2
		a[n - 1] = n - 1
	print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	(odd, even) = ([], [])
	if n % 2 == 0:
		for x in range(1, n + 1):
			odd.append(x) if x % 2 == 1 else even.append(x)
		for x in range(len(even)):
			print(f'{even[x]} {odd[x]} ', end='')
	else:
		print('3 1 2 ', end='')
		for x in range(4, n + 1):
			odd.append(x) if x % 2 == 1 else even.append(x)
		for x in range(len(even)):
			print(f'{odd[x]} {even[x]} ', end='')
	print()


def solve(n):
	ans = []
	for i in range(1, n + 1):
		ans.append(i)
	for i in range(0, n - n % 2, 2):
		(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
	if n % 2 == 1:
		(ans[-1], ans[-2]) = (ans[-2], ans[-1])
	return ans
for t in range(int(input())):
	n = int(input())
	print(*solve(n))


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


for i in range(int(input())):
	n = int(input())
	m = 1
	if n % 2 != 0:
		while m + 2 < n:
			print(m + 1, ' ', m, ' ')
			m = m + 2
		print(m + 1, ' ', m + 2, ' ', m, ' ')
	elif n % 2 == 0:
		while m < n:
			print(m + 1, ' ', m, ' ')
			m = m + 2


n = int(input())
for i in range(n):
	q = int(input())
	lst = []
	for j in range(1, q + 1):
		if j % 2 == 0:
			lst.append(j - 1)
		else:
			lst.append(j + 1)
	if q % 2 != 0 and q > 2:
		lst[-2] = q
		lst[-1] = q - 2
	print(*lst)


import bisect
import sys
import collections
import math
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 = 1000000007
for _ in range(int(input())):
	n = int(input())
	arr = []
	for i in range(1, n - 2, 2):
		print(i + 1, i, end=' ')
	if n % 2 == 0:
		print(n, n - 1, end=' ')
	else:
		print(n, n - 2, n - 1, end=' ')
	print()


for i in range(int(input())):
	n = int(input())
	s = []
	if n % 2 == 0:
		for j in range(1, n + 1):
			if j % 2 != 0:
				s.append(j + 1)
			else:
				s.append(j - 1)
	else:
		(s.append(3), s.append(1), s.append(2))
		for j in range(4, n + 1):
			if j % 2 == 0:
				s.append(j + 1)
			else:
				s.append(j - 1)
	print(*list(s), sep=' ')


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 2:
		print('2 1')
	elif n == 3:
		print('3 1 2')
	elif n == 4:
		print('2 1 4 3')
	elif n % 2 == 0:
		c = [i for i in range(2, n + 1, 2)]
		nc = [i for i in range(1, n, 2)]
		ans = []
		for i in range(len(c)):
			ans.append(str(c[i]))
			ans.append(str(nc[i]))
		print(' '.join(ans))
	else:
		ans = ['3', '1', '2']
		c = [i for i in range(4, n + 1, 2)]
		nc = [i for i in range(5, n + 1, 2)]
		for i in range(len(c)):
			ans.append(str(nc[i]))
			ans.append(str(c[i]))
		print(' '.join(ans))


from functools import reduce
import os
import sys
from collections import *
from decimal import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]

def Ceil(a, b):
	return a // b + int(a % b > 0)
albhabet = 'abcdefghijklmnopqrstuvwxyz'
mo = 1000000007
inf = 1e+18
div = 998244353
for _ in range(inn()):
	n = inn()
	a = [i for i in range(1, n + 1)]
	if n % 2 == 0:
		for i in range(0, n, 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		print(*a)
	else:
		for i in range(0, n - 3, 2):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
		(a[n - 3], a[n - 2], a[n - 1]) = (a[n - 2], a[n - 1], a[n - 3])
		print(*a)


import math
t = int(input())
for i in range(t):
	n = int(input())
	cat_queue = []
	for j in range(n):
		cat_queue.append(j + 1)
	for j in range((n - 1) // 2):
		(cat_queue[j * 2], cat_queue[j * 2 + 1]) = (cat_queue[j * 2 + 1], cat_queue[j * 2])
	(cat_queue[n - 1], cat_queue[n - 2]) = (cat_queue[n - 2], cat_queue[n - 1])
	print(' '.join(map(str, cat_queue)))


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

def solve():
	N = int(input())
	if N == 2:
		print('2 1')
	elif N == 3:
		print('3 1 2')
	elif N % 2 == 0:
		arr = list(range(1, N + 1))
		for i in range(0, N, 2):
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		print(*arr)
	else:
		arr = list(range(4, N + 1))
		for i in range(0, N - 3, 2):
			(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
		print('3 1 2', end=' ')
		print(*arr)
T = int(input())
for _ in range(T):
	solve()


t = int(input())
for k in range(t):
	n = int(input())
	ans = []
	i = 1
	if n % 2 == 1:
		ans = [3, 1, 2]
		i = 4
	while i < n:
		ans.append(i + 1)
		ans.append(i)
		i += 2
	print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = ''
	if n % 2 == 0:
		for j in range(1, n, 2):
			s += '{} {} '.format(j + 1, j)
	else:
		for j in range(1, n - 3, 2):
			s += '{} {} '.format(j + 1, j)
		s += '{} {} {}'.format(n, n - 2, n - 1)
	s.strip()
	print(s)


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


for i in range(int(input())):
	a = int(input())
	l = []
	for j in range(1, a + 1):
		l.append(j)
	for j in range(1, a, 2):
		(l[j - 1], l[j]) = (l[j], l[j - 1])
	if a & 1:
		(l[a - 3], l[a - 2], l[a - 1]) = (a, a - 2, a - 1)
	for j in l:
		print(j, end=' ')
	print()


import copy

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

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

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

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

def is_prime(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

def LSPtable(pattern):
	n = len(pattern)
	l = [0] * n
	j = 0
	for i in range(1, n):
		while j > 0 and pattern[i] != pattern[j]:
			j = l[j - 1]
		if pattern[i] == pattern[j]:
			l[i] = j + 1
			j += 1
		else:
			l[i] = 0
	return l

def KMPsearch(pattern, string):
	lsp = LSPtable(pattern)
	j = 0
	for i in range(len(string)):
		while j > 0 and string[i] != pattern[j]:
			j = lsp[j - 1]
		if string[i] == pattern[j]:
			j += 1
			if j == len(pattern):
				return i - j + 1
	return -1

def power(a, b):
	res = 1
	while b > 0:
		if b % 2:
			res *= a
		a *= a
		b = b // 2
	return res

def modInverse(a, m):
	g = gcd(a, m)
	if g != 1:
		print("Inverse doesn't exist")
	else:
		print('Modular multiplicative inverse is ', power(a, m - 2, m))

def power(x, y, m):
	if y == 0:
		return 1
	p = power(x, y // 2, m) % m
	p = p * p % m
	if y % 2 == 0:
		return p
	else:
		return x * p % m

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

def getsum(BITTree, i):
	s = 0
	while i > 0:
		s += BITTree[i]
		i -= i & -i
	return s

def updatebit(BITTree, n, i, v):
	i = i + 1
	while i <= n:
		BITTree[i] += v
		i += i & -i

def constructor(arr, n):
	BITTree = [0] * (n + 1)
	for i in range(n):
		updatebit(BITTree, n, i, arr[i])
	return BITTree

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

def mapIn():
	return map(int, input().split())
for i in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		x = 1
		y = 2
		for i in range(n):
			if i % 2:
				print(x, end=' ')
				x += 2
			else:
				print(y, end=' ')
				y += 2
		print()
	else:
		x = 1
		y = 2
		for i in range(n - 3):
			if i % 2:
				print(x, end=' ')
				x += 2
			else:
				print(y, end=' ')
				y += 2
		print(n, n - 2, n - 1)


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


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


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


takeArr = lambda : list(map(int, input().split()))
import sys
sys.setrecursionlimit(10 ** 6)
for t in range(int(input())):
	n = int(input())
	li = list(range(1, n + 1))
	for i in range(1, n, 2):
		(li[i], li[i - 1]) = (li[i - 1], li[i])
	if n % 2:
		(li[-2], li[-1]) = (li[-1], li[-2])
	print(*li)


for _ in range(int(input())):
	n = int(input())
	if n % 2:
		a = [3, 1, 2]
		for i in range(4, n, 2):
			a.append(i + 1)
			a.append(i)
	else:
		a = []
		for i in range(1, n, 2):
			a.append(i + 1)
			a.append(i)
	print(' '.join(map(str, a)))


num = int(input())
for i in range(num):
	n = int(input())
	ll = [i for i in range(1, n + 1)]
	ll.append(' ')
	ll.append(' ')
	ll.append(' ')
	aa = ll.copy()
	for t in range(0, len(ll) - 3, 2):
		ll[t] = aa[t + 1]
		ll[t + 1] = aa[t]
	ll.remove(' ')
	if n % 2 == 0:
		print(*ll)
	else:
		ll.insert(-4, n)
		ll.pop(-3)
		print(*ll)


for _ in range(int(input())):
	n = int(input())
	a = list(range(1, n + 1))
	num = n if n & 1 == 0 else n - 1
	for i in range(0, num, 2):
		(a[i], a[i + 1]) = (a[i + 1], a[i])
	if n & 1 == 1 and n >= 3:
		(a[-1], a[-2]) = (a[-2], a[-1])
	print(*a)


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

def solve():
	n = int(input())
	l = []
	if n % 2 == 0:
		for i in range(1, n, 2):
			l.append(i + 1)
			l.append(i)
		print(' '.join((str(i) for i in l)))
	elif n == 3:
		print('3', '1', '2')
	else:
		for i in range(1, n - 3, 2):
			l.append(i + 1)
			l.append(i)
		l.append(n)
		l.append(n - 2)
		l.append(n - 1)
		print(' '.join((str(i) for i in l)))
main()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		print('1')
	if n == 2:
		print('2 1')
	if n == 3:
		print('3 1 2')
	if n > 3:
		arr = list(range(1, n + 1))
		if n % 2 == 0:
			res = []
			for i in range(0, len(arr) - 1, 2):
				res.append(arr[i + 1])
				res.append(arr[i])
			print(' '.join(map(str, res)))
		else:
			res = []
			for i in range(3, len(arr) - 1, 2):
				res.append(arr[i + 1])
				res.append(arr[i])
			print('3 1 2 ' + ' '.join(map(str, res)))


from sys import stdin
lst = list(map(int, stdin.read().split()))
_s = 0

def inp(n=1):
	global _s
	ret = lst[_s:_s + n]
	_s += n
	return ret

def inp1():
	return inp()[0]
t = inp1()
for _ in range(t):
	n = inp1()
	for i in range(1, n - 2, 2):
		print(i + 1, end=' ')
		print(i, end=' ')
	print(n, end=' ')
	if n % 2 != 0:
		print(n - 2, end=' ')
	print(n - 1)


def solve(n, ans):
	arr = [i + 1 for i in range(n)]
	for i in range(0, n - 1, 2):
		(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
	if n % 2 != 0:
		(arr[-2], arr[-1]) = (arr[-1], arr[-2])
	ans.append(' '.join(map(str, arr)))

def main():
	t = int(input())
	ans = []
	for i in range(t):
		n = int(input())
		solve(n, ans)
	print('\n'.join(ans))
main()


import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby
from operator import itemgetter
for _ in range(II()):
	n = II()
	if n % 2 == 1:
		ans = [x for x in range(1, n - 2)]
		for i in range(0, len(ans), 2):
			(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
		ans.extend([n, n - 2, n - 1])
	else:
		ans = [x for x in range(1, n + 1)]
		for i in range(0, n, 2):
			(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
	print(*ans)


from sys import stdin, setrecursionlimit, maxsize
input = stdin.readline
setrecursionlimit(10 ** 6)

def f(n):
	if n == 2:
		return [2, 1]
	res = []
	idx = 1
	if n & 1 and n >= 3:
		res = [3, 1, 2]
		idx = 4
	for i in range(idx, n, 2):
		res.append(i + 1)
		res.append(i)
	return res
for _ in range(int(input())):
	n = int(input())
	print(*f(n))


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


import sys, io, os, math
try:
	yash = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
except:
	yash = lambda : sys.stdin.readline().encode()
I = lambda : [*map(int, yash().split())]
for t in range(I()[0]):
	(n,) = I()
	for i in range(1, n - 2, 2):
		sys.stdout.write(str(i + 1) + ' ')
		sys.stdout.write(str(i) + ' ')
	if not n & 1:
		sys.stdout.write(str(n) + ' ' + str(n - 1) + ' ')
	else:
		sys.stdout.write(str(n) + ' ' + str(n - 2) + ' ' + str(n - 1))
	print()


t = int(input())
for i in range(0, t):
	a = int(input())
	b = []
	d = []
	c = a - 1
	f = a - 3
	g = []
	l = f - 1
	b.append(c)
	k = 0
	l = []
	while k < a:
		c = c + 1
		b.append(c)
		c = c - 3
		b.append(c)
		k = k + 1
	for ele in b:
		if ele > 0:
			d.append(ele)
	d.reverse()
	if a % 2 == 0:
		print(*d, sep=' ')
	else:
		g = d[3:]
		l.append(3)
		l.append(1)
		l.append(2)
		for ele in g:
			l.append(ele)
		print(*l, sep=' ')


import atexit, io, sys, collections, math, heapq, fractions, copy, os
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 f(n):
	if n % 2 == 1:
		return f(n - 3) + [n, n - 2, n - 1]
	if n == 0:
		return []
	if n % 2 == 0:
		res = []
		for u in range(1, n + 1, 2):
			res.append(u + 1)
			res.append(u)
		return res
for u in range(int(input())):
	print(' '.join(list(map(str, f(int(input()))))))


for i in range(int(input())):
	n = int(input())
	s = []
	for j in range(1, n + 1):
		s.append(j)
	for j in range(0, n - 1, 2):
		(s[j], s[j + 1]) = (s[j + 1], s[j])
	if n % 2 != 0:
		(s[-2], s[-1]) = (s[-1], s[-2])
	print(*s)


for t in range(int(input())):
	n = int(input())
	L = []
	for i in range(n):
		L.append(i + 1)
	if n % 2 == 0:
		i = 0
		while i < n:
			(L[i], L[i + 1]) = (L[i + 1], L[i])
			i += 2
	else:
		(L[0], L[1], L[2]) = (3, 1, 2)
		i = 3
		while i < n:
			(L[i], L[i + 1]) = (L[i + 1], L[i])
			i += 2
	for i in range(n):
		if i == n - 1:
			print(L[i])
		else:
			print(L[i], end=' ')


for _ in range(int(input())):
	x = int(input())
	if x % 2 == 0:
		l = []
		for i in range(1, x + 1, 2):
			l.append(i + 1)
			l.append(i)
		print(*l)
	elif x >= 3:
		l = [3, 1, 2]
		for i in range(4, x + 1, 2):
			l.append(i + 1)
			l.append(i)
		print(*l)


T = int(input())
for _ in range(T):
	n = int(input())
	A = []
	if n % 2 == 0:
		for i in range(n // 2):
			A.append(1 + 2 * i + 1)
			A.append(1 + 2 * i)
	else:
		A = [3, 1, 2]
		for i in range(1, n // 2):
			A.append(1 + 2 * i + 2)
			A.append(1 + 2 * i + 1)
	print(' '.join((str(a) for a in A)))


import sys
from math import factorial
input = sys.stdin.readline
INF = int(1000000000.0) + 7

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


for nt in range(int(input())):
	n = int(input())
	if n % 2 == 0:
		ans = []
		for i in range(1, n, 2):
			ans.append(i + 1)
			ans.append(i)
		print(*ans)
	else:
		ans = [3, 1, 2]
		for i in range(4, n + 1, 2):
			ans.append(i + 1)
			ans.append(i)
		print(*ans)


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


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


while True:
	try:
		t = eval(input())
		for i in range(t):
			n = eval(input())
			if n % 2 == 0:
				for j in range(1, n, 2):
					if j != n - 1:
						print(j + 1, j, end=' ')
					else:
						print(j + 1, j, end='\n')
			else:
				for j in range(1, n - 2, 2):
					print(j + 1, j, end=' ')
				print(n - 1, n, n - 2, end='\n')
	except:
		break