## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

# [Solution] Woeful Permutation Codeforces Solution

B. Woeful Permutation
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a positive integer 𝑛

Find any permutation $p$ of length $n$ such that the sum $\mathrm{lcm}\left(1,{p}_{1}\right)+\mathrm{lcm}\left(2,{p}_{2}\right)+\dots +\mathrm{lcm}\left(n,{p}_{n}\right)$ is as large as possible.

Here $\mathrm{lcm}\left(x,y\right)$ denotes the least common multiple (LCM) of integers $x$ and $y$.

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

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1\le t\le 1\phantom{\rule{thinmathspace}{0ex}}000$).

Solution Click Below:-  👉
👇👇👇👇👇

Description of the test cases follows.

The only line for each test case contains a single integer $n$ ($1\le n\le {10}^{5}$).

It is guaranteed that the sum of $n$ over all test cases does not exceed ${10}^{5}$.

Output

For each test case print $n$ integers ${p}_{1}$${p}_{2}$$\dots$${p}_{n}$ — the permutation with the maximum possible value of $\mathrm{lcm}\left(1,{p}_{1}\right)+\mathrm{lcm}\left(2,{p}_{2}\right)+\dots +\mathrm{lcm}\left(n,{p}_{n}\right)$.

If there are multiple answers, print any of them.