## GUPTA MECHANICAL

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

# [Solution] Circular Xor Reversal Codeforces Solution

F. Circular Xor Reversal
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You have an array ${a}_{0},{a}_{1},\dots ,{a}_{n-1}$ of length $n$. Initially, ${a}_{i}={2}^{i}$ for all $0\le i. Note that array $a$ is zero-indexed.

You want to reverse this array (that is, make ${a}_{i}$ equal to ${2}^{n-1-i}$ for all $0\le i). To do this, you can perform the following operation no more than $250\phantom{\rule{thinmathspace}{0ex}}000$ times:

• Select an integer $i$ ($0\le i) and replace ${a}_{i}$ by ${a}_{i}\oplus {a}_{\left(i+1\right)modn}$.

Here, $\oplus$ denotes the bitwise XOR operation.

Your task is to find any sequence of operations that will result in the array $a$ being reversed. It can be shown that under the given constraints, a solution always exists.

Input

The first line contains a single integer $n$ ($2\le n\le 400$) — the length of the array $a$.

Output

On the first line print one integer $k$ ($0\le k\le 250\phantom{\rule{thinmathspace}{0ex}}000$) — the number of operations performed.

On the second line print $k$ integers ${i}_{1},{i}_{2},\dots ,{i}_{k}$ ($0\le {i}_{j}). Here, ${i}_{j}$ should be the integer selected on the $j$-th operation.

Note that you don't need to minimize the number of operations.

Note

In the notes, the elements on which the operations are performed are colored red.

In the first test case, array $a$ will change in the following way:

$\left[1,2\right]\to \left[1,3\right]\to \left[2,3\right]\to \left[2,1\right]$.

In the second test case, array $a$ will change in the following way: