'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for q in range(n-1, 0, -1):
        qc.cx(q, q-1)
        qc.cx(q-1, q)
        qc.cx(q, q-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2, -1, -1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        qc.cx(i, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1, 0, -1):
        qc.cx(i - 1, i)
    qc.cx(n-1, 0)
    return qc
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1, 0, -1):
        qc.cx(i - 1, i)
    qc.cx(n-1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(i, i + 1)
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2):
        qc.cx(0, i + 1)
        qc.cx(i + 1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(0, i + 1)
        qc.cx(i + 1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(0, i + 1)
        qc.cx(i + 1, 0)
        qc.cx(0, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    qc.cx(n - 1, 0)
    qc.cx(0, n - 1)
    qc.cx(n - 1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n == 2:
        qc.cx(0, 1)
        qc.cx(1, 0)
        qc.cx(0, 1)
    else:
        for i in range(n - 1):
            qc.cx(i, i + 1)
            qc.cx(i + 1, i)
            qc.cx(i, i + 1)
        qc.cx(n - 1, 0)
        qc.cx(0, n - 1)
        qc.cx(n - 1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(1, n):
        qc.cx(0,i)
        qc.cx(i,0)
        qc.cx(0,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for _ in range(n-2,-1,-1):
        qc.cx(_,_+1)
        qc.cx(_+1,_)
        qc.cx(_,_+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(n-1, n)
        qc.cx(n, n-1)
        qc.cx(n-1, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.swap(i, i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve() -> QuantumCircuit:
    qc = QuantumCircuit(2)
    for i in range(n-1):
        qc.cx(i, i+1)

    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n) -> QuantumCircuit:
    qc = QuantumCircuit(2)
    for i in range(n-1):
        qc.cx(i, i+1)

    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(2)
    for i in range(n-1):
        qc.cx(i, i+1)

    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i, i+1)

    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(1, n):
        qc.cx(i, i-1)

    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(1, N):
        # 1 ~ N-1까지 반복
        at = N-i-1
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-2, 0, -1):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(at, at+1)
        qc.cx(at+1, at)
        qc.cx(at, at+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx((n-i)%n, n-i-1)
        qc.cx(n-i-1, (n-i)%n)
        qc.cx((n-i)%n, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.cx(i, (i + 1) % n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.cx(i, (i + 1) % n)
        qc.cx((i + 1) % n, i)
        qc.cx(i, (i + 1) % n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i, n-1)
        qc.cx(n-1, i)
        qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, -1, -1):
        qc.cx(i, i-1);
        qc.cx(i-1, i)
        qc.cx(i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i, i-1)
        qc.cx(i-1, i)
        qc.cx(i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1, 0, -1):
        qc.cx(i - 1, i)
        qc.cx(i, i - 1)
        qc.cx(i - 1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math

def solve(n) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def _swap(i, j):
        #qc.swap(i, j)
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

    curr = list(range(n))
    while True:
        need_replace = []

        for idx in range(n):
            if curr[idx] != (idx + n - 1) % n:
                need_replace.append(idx)

        for idx in range(0, len(need_replace), 2):
            if idx+1 >= len(need_replace):
                continue

            a = need_replace[idx]
            b = need_replace[idx + 1]
            _swap(a, b)
            curr[a], curr[b] = curr[b], curr[a]

        if len(need_replace) == 0:
            break

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap(qc: QuantumCircuit, a: int, b: int) -> None:
    qc.cx(a, b)
    qc.cx(b, a)
    qc.cx(a, b)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n - 1, 0, -1):
        swap(qc, i, i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        x = (i + 1) % n
        qc.cx(i, x)
        qc.cx(x, i)
        qc.cx(i, x)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i, x)
        qc.cx(x, i)
        qc.cx(i, x)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        x = i+1
        qc.cx(i, x)
        qc.cx(x, i)
        qc.cx(i, x)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1, -1, -1):
        x = i+1
        qc.cx(i, x)
        qc.cx(x, i)
        qc.cx(i, x)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-2, -1, -1):
        x = i+1
        qc.cx(i, x)
        qc.cx(x, i)
        qc.cx(i, x)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.swap(i,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    swap(qc, 0, n-1)
    for i in range(n - 1):
        swap(qc, n - i - 1, n - i - 2)

    return qc

def swap(qc, q1, q2) -> QuantumCircuit:
    qc.cx(q1, q2)
    qc.cx(q2, q1)
    qc.cx(q1, q2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    swap(qc, 0, n-1)
    for i in range(n - 2):
        swap(qc, n - i - 1, n - i - 2)

    return qc

def swap(qc, q1, q2) -> QuantumCircuit:
    qc.cx(q1, q2)
    qc.cx(q2, q1)
    qc.cx(q1, q2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(n - 1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n)
    for i in range(1, n):
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n)
    for i in range(1, n):
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(1, n-1):
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(1, n-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(1, n-1):
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(0, n-2):
        qc.cx(i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(0, n-2):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(0, n-2):
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.x(0)
    for i in range(0, n-1):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.(0)
    for i in range(0, n-2):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.(0)
    for i in range(0, n-2):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.x(0)
    for i in range(0, n-2):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.x(0)
    for i in range(1, n-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    for i in range(n-1, 1, -1):
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    for i in range(n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(1, n-1):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    for i in range(n-1, 1, -1):
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    for i in range(n-1, 2, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    for i in range(n-2, 1, -1):
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.swap(0,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(0,i+1)
        qc.cx(i+1,0)
        qc.cx(0,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for _ in reversed(range(n - 1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n - 1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.x(0)
    qc.cx(0,1)
    qc.cx(1,0)
    qc.cx(0,1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2, -1):
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2, -1, -1):
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # CNOT3つでSWAPを実装する関数
    def swap_with_cnot(a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    # 右端(n-1番量子ビット)を左へずらす → 次に(n-2)番をずらす → ... の順
    # 具体例: n=3の場合、qubit2<->qubit1、続いてqubit1<->qubit0 の順
    for i in range(n-1, 0, -1):
        swap_with_cnot(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,0):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,0,-1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,-1,-1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2, -1, -1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(1,n):
        qc.cx(i-1,i)
        qc.cx(i,i-1)
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,-1,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    for i in range(0,len(qc)):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    for n in range(0,len(qc)):
        qc.cx(n-1, n)
        qc.cx(n, n-1)
        qc.cx(n-1, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    for i in range(0,n):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    for i in range(0,n):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    for i in range(0,n):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(0,n):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(0,n-1):
        qc.cx(i,n-1)
        qc.cx(n-1,i)
        qc.cx(i,n-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i,n-1-i)
        qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i,n-1-i)
        qc.cx(n-1-i,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n >= 2 and n <= 10:
        for i in range(n):
            qc.cx(i,n-1-i)
            qc.cx(n-1-i,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n >= 2 and n <= 10:
        for i in range(n):
            qc.cx(i,n-1-i)
            qc.cx(n-1-i,i)

        return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n):
        qc.cx(i,n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n//2):
        qc.cx(i,n-1-i)
        qc.cx(n-1-i,i)
        qc.cx(i,n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n):
        qc.cx(i,n-1-i)
        qc.cx(n-1-i,i)
        qc.cx(i,n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n//2):
        qc.cx(i,(n-1-i))
        qc.cx((n-1-i),i)
        qc.cx(i,(n-1-i))

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n//2):
        qc.cx(i,(n-1-i))
        qc.cx((n-1-i),i)
        qc.cx(i,(n-1-i))
        qc.barrier()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n//2):
        qc.cx(i,(n-i-1))
        qc.cx((n-i-1),i)
        qc.cx(i,(n-i-1))
        qc.barrier()

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here
    for i in range(n-1):
        qc.cx(i,i+1)
    qc.cx(n-1,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    def swap(n, i, j) -> QuantumCircuit:
        qc = QuantumCircuit(n)

        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

        return qc

    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(n-1)):
        qc.compose(swap(n, i, i + 1), inplace=True)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
    qc.cx(i-1, i)
    qc.cx(i, i-1)
    qc.cx(i-1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(n - i - 2, n - i - 1)
        qc.cx(n - i - 1, n - i - 2)
        qc.cx(n - i - 2, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(n - i - 2, n - i - 1)
        qc.cx(n - i - 1, n - i - 2)
        qc.cx(n - i - 2, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n - 1):
        qc.cx(i, n - 1)      # Step 1: CNOT with control q_i and target q_{n-1}
        qc.cx(n - 1, i)      # Step 2: CNOT with control q_{n-1} and target q_i
        qc.cx(i, n - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i, (i + 1) % n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if i == n - 1:
            qc.cx(i, 0)
            qc.cx(0, i)
            qc.cx(i, 0)
        else:
            qc.cx(i, i + 1)
            qc.cx(i + 1, i)
            qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        j = (n-1) - i
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-1, 0, -1):
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    def cnot_swap(qc, q1, q2):
        qc.cx(q1, q2)
        qc.cx(q2, q1)
        qc.cx(q1, q2)

    for i in range(n-1):
        cnot_swap(0, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    def cnot_swap(qc, q1, q2):
        qc.cx(q1, q2)
        qc.cx(q2, q1)
        qc.cx(q1, q2)

    # quantum left shift
    for i in range(n-1):
        cnot_swap(qc, 0, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        last = n - 1 - i
        qc.cx(last, last - 1)
        qc.cx(last - 1, last)
        qc.cx(last, last - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cx(n-1,0)
    qc.cx(0,n-1)
    qc.cx(n-1,0)

    for i in range(1, n-2):#i and n-1
        qc.cx(n-1,i)
        qc.cx(i,n-1)
        qc.cx(n-1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cx(n-1,0)
    qc.cx(0,n-1)
    qc.cx(n-1,0)

    for i in range(1, n-1):#i and n-1
        qc.cx(n-1,i)
        qc.cx(i,n-1)
        qc.cx(n-1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(n - i    , n - i    )
        qc.cx(n - i - 1, n - i - 1)
        qc.cx(n - i    , n - i    )

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(0, n - 1):
        qc.cx(n - i    , n - i    )
        qc.cx(n - i - 1, n - i - 1)
        qc.cx(n - i    , n - i    )

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(0, n - 1):
        qc.cx(n - i    , n - i - 1)
        qc.cx(n - i - 1, n - i    )
        qc.cx(n - i    , n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(0, n - 1)):
        qc.cx(i - 1, i    )
        qc.cx(i    , i - 1)
        qc.cx(i - 1, i    )

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np
# from qiskit.quantum_info import Statevector

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc

# if __name__ == "__main__":
#     qc = solve(3)
#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit
import numpy as np
# from qiskit.quantum_info import Statevector

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc

# if __name__ == "__main__":
#     qc = solve(3)
#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(0, n-1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(0, n-1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.cx(i,(i+1)%n)
        qc.cx(i,(i+1)%n)
        qc.cx(i,(i+1)%n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        qc.cx(i,(i+1)%n)
        qc.cx((i+1)%n,i)
        qc.cx(i,(i+1)%n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n,1,-1):
        qc.cx(i,i-1)
        qc.cx(i-1,i)
        qc.cx(i,i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1,0,-1):
        qc.cx(i,i-1)
        qc.cx(i-1,i)
        qc.cx(i,i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n) -> QuantumCircuit:
	qc = QuantumCircuit(n)
	for i in reversed(range(n - 1)):
		qc.swap(i, i + 1)
	return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n) -> QuantumCircuit:
	qc = QuantumCircuit(n)
	for i in reversed(range(n - 1)):
		qc.cx(i, i + 1)
		qc.cx(i + 1, i)
		qc.cx(i, i + 1)
	return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i,i+1)
    qc.cx(n-1,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i,i+1)
        qc.cx(i+1,1)
        qc.cx(i,i+1)
    qc.cx(n-1,0)
    qc.cx(0,n-1)
    qc.cx(n-1,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i,i+1)
    for i in range(n-1):
        qc.cx(i+1,1)
    for i in range(n-1):
        qc.cx(i,i+1)
    qc.cx(n-1,0)
    qc.cx(0,n-1)
    qc.cx(n-1,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)
    swap(qc, n-1, 0)
    for i in range(n-2, -1, -1):
        swap(qc, i, i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)
    swap(qc, n-1, 0)
    for i in range(n-2, 0, -1):
        swap(qc, i, i+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n//2):
        qc.cx(i*2,i*2+1)
        qc.cx(i*2+1,i*2)
        qc.cx(i*2,i*2+1)
    for i in range(-(-n//2)//2):
        qc.cx(i*4,i*4+2)
        qc.cx(i*4+2,i*4)
        qc.cx(i*4,i*4+2)
    for i in range(-(-n//4)//2):
        qc.cx(i*8,i*8+4)
        qc.cx(i*8+4,i*8)
        qc.cx(i*8,i*8+4)
    for i in range(-(-n//8)//2):
        qc.cx(i*16,i*16+8)
        qc.cx(i*16+8,i*16)
        qc.cx(i*16,i*16+4)

    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n//2):
        qc.cx(i*2,i*2+1)
        qc.cx(i*2+1,i*2)
        qc.cx(i*2,i*2+1)
    for i in range(-(-n//2)//2):
        qc.cx(i*4,i*4+2)
        qc.cx(i*4+2,i*4)
        qc.cx(i*4,i*4+2)
    for i in range(-(-n//4)//2):
        qc.cx(i*8,i*8+4)
        qc.cx(i*8+4,i*8)
        qc.cx(i*8,i*8+4)
    for i in range(-(-n//8)//2):
        qc.cx(i*16,i*16+8)
        qc.cx(i*16+8,i*16)
        qc.cx(i*16,i*16+8)

    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

from qiskit.circuit.library import HGate, ZGate, XGate, PhaseGate
import math

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i+1, 0)
        qc.cx(0, i+1)
        qc.cx(i+1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)
        qc.cx(i-1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-2, n-1)
        qc.cx(n-1, n-2)
        qc.cx(n-2, n-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-2-i, n-1-i)
        qc.cx(n-1-i, n-2-i)
        qc.cx(n-2-i, n-1-i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, n-1)
        qc.cx(n-1, i)
        qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2, -1, -1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
    for i in range(n-1)[::-1]:
        qc.cx(i+1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
    qc.cx(0, 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cx(n-1, 0)
    qc.cx(n-2, n-1)
    for i in range(n-2, 0, -1):
        qc.cx(i, i + 1)
    qc.cx(0, n-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    for i in range(n-1):
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    qc.cx(0, 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    for i in range(1, n-1)[::-1]:
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.swap(n - 2 - i, n - 1 - i)
        qc.swap(n - 1 - i, n - 2 - i)
        qc.swap(n - 2 - i, n - 1 - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(n - 2 - i, n - 1 - i)
        qc.cx(n - 1 - i, n - 2 - i)
        qc.cx(n - 2 - i, n - 1 - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        j = n-1-i
        k = n-2-i
        qc.cx(j,k)
        qc.cx(k,j)
        qc.cx(j,k)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        qc.cx(i, n - 1 - i)
        qc.cx(n - 1 - i, i)
        qc.cx(i, n - 1 - i)
    for i in range(1, n//2 + n%2):
        qc.cx(i, n - i)
        qc.cx(n - i, i)
        qc.cx(i, n - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        qc.cx(i,i-1)
        qc.cx(i-1,i)
        qc.cx(i,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Move the last qubit to the first position
    for i in range(n-1):
        qc.cx(n-1, i)  # CNOT from qubit n-1 to qubit i

    # Move the first qubit to the second position
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)  # CNOT from qubit i-1 to qubit i

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap_gate(qc, i, j)
    qc.cx(i, j)
    qc.cx(j, i)
    qc.cx(i, j)
    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    #i refers to x_{n-1}
    for i in range(n-1, 0, -1):
        qc = swap_gate(qc, i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap_gate(qc, i, j):
    qc.cx(i, j)
    qc.cx(j, i)
    qc.cx(i, j)
    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    #i refers to x_{n-1}
    for i in range(n-1, 0, -1):
        qc = swap_gate(qc, i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    swap = QuantumCircuit(2)
    swap.cx(0,1)
    swap.cx(1,0)
    swap.cx(0,1)

    for i in range(n-1):
        i_first=i
        i_second=(i+1) % n
        qc.append(swap.to_instruction(), [i_first, i_second])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-1):
        i_first=i
        i_second=(i+1) % n
        qc.cx(i_first, i_second)
        qc.cx(i_second, i_first)
        qc.cx(i_first, i_second)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in reversed(range(n-1)):
        i_first=i
        i_second=(i+1) % n
        qc.cx(i_first, i_second)
        qc.cx(i_second, i_first)
        qc.cx(i_first, i_second)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if n-i-2 < 0:
            break
        qc.cx(n-i-2,n-i-1)
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc,k,l):
        qc.cx(k,l)
        qc.cx(l,k)
        qc.cx(k,l)
        return qc

    for j in range(n):
        qc=swap(qc,j,(j+1)%n)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc,k,l):
        qc.cx(k,l)
        qc.cx(l,k)
        qc.cx(k,l)
        return qc

    for j in range(n-1):
        qc=swap(qc,0,j+1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Write your code here:
    for i in range(n-1):
        qc.cx(i, i+1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def swap(a,b):
    	qc.cx(a,b)
    	qc.cx(b,a)
    	qc.cx(a,b)

    for i in range(n-1)[::-1]:
    	swap(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(1, n):
        qc.cx(0, i)
        qc.cx(i, 0)
        qc.cx(0, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n // 2):

        qc.cx(i, n - i - 1)
        qc.cx(n - i - 1, i)
        qc.cx(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i, i-1)
        qc.cx(i-1, i)
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

     for i in range(n-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

     for i in range(n-1,0,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

     for i in range(n-1,0,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    for i in range(n-1,0,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1,0,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1,1,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    for i in range(n-1,1,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(n-1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n)
        for j in range(n)
            for k in range(n)
                qc.cx(j,k+1)

    for l in range(n)
        qc.cx(0,l+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n)
        for j in range(n)
            for k in range(n)
                qc.cx(j,k)

    for l in range(n)
        qc.cx(0,l)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n, -1, 0):
        qc.cx(i, i - 1)
        qc.cx(i - 1, i)
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n, 0, -1):
        qc.cx(i, i - 1)
        qc.cx(i - 1, i)
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i, i - 1)
        qc.cx(i - 1, i)
        qc.cx(i, i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    j = n-1
    while j >= 3:
        qc.cx(j, j-1)
        qc.cx(j-1, j)
        qc.cx(j, j-1)

        qc.cx(j-2, j-3)
        qc.cx(j-3, j-2)
        qc.cx(j-2, j-3)

        qc.cx(j-1, j-3)
        qc.cx(j-3, j-1)
        qc.cx(j-1, j-3)
        j -= 3

    while j > 0:
        qc.cx(j, j-1)
        qc.cx(j-1, j)
        qc.cx(j, j-1)
        j -= 1

    #"""
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        swap(qc, n - i - 1, n - i - 2)

    return qc

def swap(qc, q1, q2) -> QuantumCircuit:
    qc.cx(q1, q2)
    qc.cx(q2, q1)
    qc.cx(q1, q2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        swap(qc, n - i - 1, n - i - 2)

    return qc

def swap(qc, q1, q2) -> QuantumCircuit:

    qc.cx(q2, q1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        swap(qc, n - i - 1, n - i - 2)

    return qc

def swap(qc, q1, q2) -> QuantumCircuit:

    qc.cx(q2, q1)
    qc.cx(q1, q2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n - 1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(1, n)):
        qc.cx(i-1, i)

    for i in range(1, n):
        qc.cx(i-1, i)

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(1, n)):
        qc.cx(i-1, i)
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        swap(qc, n-1, i)

    return qc

def swap(qc, a, b):
    qc.cx(a, b)
    qc.cx(b, a)
    qc.cx(a, b)
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i, n-1)
        qc.cx(n-1, i)
        qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(n-1, i)
        qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1):
        qc.cx(i, n-1)
        qc.cx(n-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap_gate(qc, i, j):
    qc.cx(i, j)
    qc.cx(j, i)
    qc.cx(i, j)
    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    #i refers to x_{n-1}
    for i in range(n-1, 0, -1):
        qc = swap_gate(qc, i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap_gate(qc, i, j):
    qc.cx(j, i)
    qc.cx(i, j)
    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    #i refers to x_{n-1}
    for i in range(n-1, 0, -1):
        qc = swap_gate(qc, i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.reset(0)

    for i in range(n-1,1,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)

    for i in range(n-1,1,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.reset(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1,1,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.reset(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1,0,-1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    qc.reset(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,-1,-1):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    qc.reset(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0, -1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1, 2):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    for i in range(n - 1, 2):
        qc.cx(n - i - 3, n - i - 1)
        qc.cx(n - i - 1, n - i - 3)
        qc.cx(n - i - 3, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(0, n - 1, 2):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    s = (n+1)%2
    for i in range(s, n - 2, 2):
        qc.cx(n- i - 3, n- i - 1)
        qc.cx(n- i - 1, n-i - 3)
        qc.cx(n-i - 3, n-i - 1)
        print(n-i-1, n-i-3)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n//2):
        qc.cx(i*2,i*2+1)
        qc.cx(i*2+1,i*2)
        qc.cx(i*2,i*2+1)
    for i in range(-(-n//2)//2):
        qc.cx(i*4,i*4+2)
        qc.cx(i*4+2,i*4)
        qc.cx(i*4,i*4+2)
    for i in range(-(-n//4)//2):
        qc.cx(i*8,i*8+4)
        qc.cx(i*8+4,i*8)
        qc.cx(i*8,i*8+4)
    for i in range(-(-n//8)//2):
        qc.cx(i*16,i*16+8)
        qc.cx(i*16+8,i*16)
        qc.cx(i*16,i*16+8)
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n//2):
        qc.cx(i*2,i*2+1)
        qc.cx(i*2+1,i*2)
        qc.cx(i*2,i*2+1)
    for i in range(-(-n//2)//2):
        qc.cx(i*4,i*4+2)
        qc.cx(i*4+2,i*4)
        qc.cx(i*4,i*4+2)
    for i in range(-(-n//4)//2):
        qc.cx(i*8,i*8+4)
        qc.cx(i*8+4,i*8)
        qc.cx(i*8,i*8+4)
    for i in range(-(-n//8)//2):
        qc.cx(i*16,i*16+8)
        qc.cx(i*16+8,i*16)
        qc.cx(i*16,i*16+8)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta = 2 * arccos(1 / sqrt(3))
    qc.ry(theta, 0)
    qc.cx(0, 1)
    qc.cz(0, 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    theta = 2 * np.arccos(1 / np.sqrt(3))
    qc.ry(theta, 0)
    qc.cx(0, 1)
    qc.cz(0, 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 2, 0, -1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n == 2:
        # n=2 の場合、x0 を x1 に移動するだけ
        qc.cx(0, 1)
        qc.cx(1, 0)
        qc.cx(0, 1)
    else:
        # 一般的な n の場合
        for i in range(n - 2, -1, -1):  # x_0 から x_{n-2} まで右にシフト
            qc.cx(i, i + 1)
            qc.cx(i + 1, i)
            qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import numpy as np

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n == 2:
        qc.cx(0, 1)
    else:
        for i in range(n - 2, -1, -1):
            qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n == 2:
        qc.cx(0, 1)
        qc.cx(1, 0)
        qc.cx(0, 1)
    else:
        # n>2 の場合
        # 1. x_0 を x_{n-1} の位置に移動 (CX ゲートを使用)
        qc.cx(0, n-1)
        qc.cx(n-1, 0)
        qc.cx(0, n-1)

        # 2. x_1 から x_{n-2} を左に1ビットシフト (CX ゲートを使用)
        for i in range(1, n-1):
            qc.cx(i, i+1)
            qc.cx(i+1, i)
            qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # x_{n-1} を x_0 の位置に移動
    for i in range(n - 1):
        qc.cx(n - 1, i)
        qc.cx(i, n - 1)
        qc.cx(n - 1, i)

    # x_0 から x_{n-2} までのビットを右に 1 つずつシフト
    for i in range(n - 2, 0, -1):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # x_{n-1} を x_0 の位置に移動
    qc.x(n-1)
    qc.cx(n-1,0)
    qc.x(n-1)
    qc.x(0)

    # x_0 から x_{n-2} までのビットを右に 1 つずつシフト
    for i in range(1,n):
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # 最後の量子ビットを保存するために一時的に古い値を保持する
    for i in range(n - 1):
        qc.cx(i, i + 1)  # 量子ビット間でCNOTゲートを使って状態を転送

    # 最後の量子ビットを最初に持ってくる
    qc.cx(n - 1, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n) -> QuantumCircuit:
	qc = QuantumCircuit(n)
	def make(l, r):
		if r - l == 1:
			return
		m = l + r >> 1
		make(l, m)
		make(m, r)
		qc.cx(l, m)
		qc.cx(m, l)
		qc.cx(l, m)
	make(0, n)
	return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math

def solve(n) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def _swap(i, j):
        #qc.swap(i, j)
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

    curr = list(range(n))
    while True:
        need_replace = []

        for idx in range(n):
            if curr[idx] != (idx + 1) % n:
                need_replace.append(idx)

        for idx in range(0, len(need_replace), 2):
            if idx+1 >= len(need_replace):
                continue

            a = need_replace[idx]
            b = need_replace[idx + 1]
            _swap(a, b)
            curr[a], curr[b] = curr[b], curr[a]

        if len(need_replace) == 0:
            break

    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
import numpy as np
import math

def solve(n) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def _swap(i, j):
        #qc.swap(i, j)
        qc.cx(i, j)
        qc.cx(j, i)
        qc.cx(i, j)

    curr = list(range(n))
    while True:
        need_replace = []

        for idx in range(n):
            if curr[idx] != (idx + n - 1) % n:
                need_replace.append(idx)

        for idx in range(0, len(need_replace), 2):
            if idx+1 >= len(need_replace):
                continue

            a = need_replace[idx]
            b = need_replace[idx + 1]
            _swap(a, b)
            curr[a], curr[b] = curr[b], curr[a]

        if len(need_replace) == 0:
            break

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(, n)):
        qc.cx(i-1,i)
        qc.cx(i-0,i-1)
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(1, n)):
        qc.cx(i-1,i)
        qc.cx(i-0,i-1)
        qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    swap = np.array([1,0,0,0],
                    [0,0,1,0],
                    [0,1,0,0],
                    [0,0,0,1])
    for i in reversed(range(0, n)):
        qc.append(UnitaryGate(swap),[i-1,i])
        # qc.cx(i-0,i-1)
        # qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    swap = np.array([[1,0,0,0],
                    [0,0,1,0],
                    [0,1,0,0],
                    [0,0,0,1]])
    for i in reversed(range(0, n)):
        qc.append(UnitaryGate(swap),[i-1,i])
        # qc.cx(i-0,i-1)
        # qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    swap = np.array([[1,0,0,0],
                    [0,0,1,0],
                    [0,1,0,0],
                    [0,0,0,1]])
    for i in reversed(range(0, n)):
        qc.append(Operator(swap),[i-1,i])
        # qc.cx(i-0,i-1)
        # qc.cx(i-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in reversed(range(n - 1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n - 1):
        qc.cx(i, n - 1)      # Step 1: CNOT with control q_i and target q_{n-1}
        qc.cx(n - 1, i)      # Step 2: CNOT with control q_{n-1} and target q_i
        qc.cx(i, n - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    half = n // 2

    # Layer 1: For each pair, do the first CNOT.
    for i in range(half):
        qc.cx(i, n - i - 1)

    # Layer 2: For each pair, do the second CNOT.
    for i in range(half):
        qc.cx(n - i - 1, i)

    # Layer 3: For each pair, do the third CNOT.
    for i in range(half):
        qc.cx(i, n - i - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)  # Copy the content of q[i] into q[i+1] (which is 0)
        qc.cx(i+1, i)  #

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
    qc.cx(i-1,i)
    qc.cx(i,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        qc.cx(i,i-1)
        qc.cx(i-1,i)
        qc.cx(i,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        #qc.cx(i,i-1)
        qc.cx(i-1,i)
        qc.cx(i,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n // 2):
        qc.cx(i, n - 1 - i)
        qc.cx(n - 1 - i, i)
        qc.cx(i, n - 1 - i)

    for j in range((n - 1) // 2):
        qc.cx(1 + j, n - 1 - j)
        qc.cx(n - 1 - j, 1 + j)
        qc.cx(1 + j, n - 1 - j)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if n-i-2 < 0:
            break
        qc.cx(n-i-2,n-i-1)
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if n-i-2 < 0:
            break
        qc.cx(n-i-2,n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if n-i-2 < 0:
            break
        qc.cx(n-i-2,n-i-1)
        qc.cx(n-i-1,n-i-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # n qubitのn番目のqubitを0番目にスワップする、swapゲートを使わない実装
    # Xn-1=0 の条件あり
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(0, n-2):
        qc.cx(i,n-2)
        qc.cx(n-2,i)
        qc.cx(i,n-2)

    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(0, n-1):
        qc.cx(i,n-1)
        qc.cx(n-1,i)
        qc.cx(i,n-1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    qc.x(0)

    for i in range(1, n-2):
        qc.cx(i,n-2)
        qc.cx(n-2,i)
        qc.cx(i,n-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.cx(0, n-1)
    qc.cx(n-1, 0)
    qc.cx(0, n-1)
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n//2):
        qc.cx(i, n-1-i)
        qc.cx(n-1-i, i)
        qc.cx(i, n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-1, n-i-2)
        qc.cx(n-i-2, n-i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def my_swap(qc, q1, q2):
    qc.cx(q1, q2)
    qc.cx(q2, q1)
    qc.cx(q1, q2)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
    	my_swap(qc, i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def my_swap(qc, q1, q2):
    qc.cx(q1, q2)
    qc.cx(q2, q1)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
    	my_swap(qc, i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(n-1)

    for i in range(2, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.ccx(n-1, at, at+1)
        qc.ccx(n-1, at+1, at)
        qc.ccx(n-1, at, at+1)

    # qc가 1이면 0과 n-1을 swap
    # qc가 0이면 swap하지 않음

    qc.x(0)
    qc.cx(0, n-1)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(at, at+1)
        qc.cx(at+1, at)
        qc.cx(at, at+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(n-1)

    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(at, at+1)
        qc.cx(at+1, at)

    qc.cx(n-1, 0)
    qc.cx(0, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.x(n-1)

    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        qc.cx(at, at+1)
        qc.cx(at+1, at)

    #qc.cx(n-1, 0)
    #qc.cx(0, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(1, n):
        # 1 ~ N-1까지 반복
        at = n-i-1
        # at를 at+1로 밀기
        qc.cx(at, at+1)
        qc.cx(at+1, at)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Apply CNOT gates to perform the cyclic shift
    for i in range(n - 1):
        qc.cx(i, i + 1)  # Move x_i to x_(i+1)

    # Move the last qubit (which is always 0) to the first position
    qc.cx(n - 1, 0)  # Move x_(n-1) to x_0

    return qc
'''


'''python
from qiskit import QuantumCircuit

def A3(n: int) -> QuantumCircuit:
    def swap(n: int, qubit1: int, qubit2: int) -> QuantumCircuit:
        qc = QuantumCircuit(n)

        qc.cx(qubit1, qubit2)
        qc.cx(qubit2, qubit1)
        qc.cx(qubit1, qubit2)

        return qc

    qc = QuantumCircuit(n)

    for i in reversed(range(n - 1)):
        qc.compose(swap(n, i, i + 1), inplace=True)

    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    A3_circuit = A3(n).to_instruction(label="A2")
    qc.compose(A3_circuit, inplace=True)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def A3(n: int) -> QuantumCircuit:
    def swap(n: int, qubit1: int, qubit2: int) -> QuantumCircuit:
        qc = QuantumCircuit(n)

        qc.cx(qubit1, qubit2)
        qc.cx(qubit2, qubit1)
        qc.cx(qubit1, qubit2)

        return qc

    qc = QuantumCircuit(n)

    for i in reversed(range(n - 1)):
        qc.compose(swap(n, i, i + 1), inplace=True)

    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.compose(A3(n), inplace=True)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def A3(n: int) -> QuantumCircuit:
    def swap(n: int, qubit1: int, qubit2: int) -> QuantumCircuit:
        qc = QuantumCircuit(n)

        qc.cx(qubit1, qubit2)
        qc.cx(qubit2, qubit1)
        qc.cx(qubit1, qubit2)

        return qc

    qc = QuantumCircuit(n)

    for i in reversed(range(n - 1)):
        qc.compose(swap(n, i, i + 1), inplace=True)

    return qc

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    qc.compose(A3(n).to_instruction(), inplace=True)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc,i,j):
        qc.cx(i,j)
        qc.cx(j,i)
        qc.cx(i,j)
    for i in range(n//2):
        swap(qc,2*i,2*i+1)
    for j in range(n-(n%2==0),2,-2):
        swap(qc,j,j-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> qt.QuantumCircuit:
    qc = qt.QuantumCircuit(n)
    # Write your code here:
    def swap(qc,i,j):
        qc.cx(i,j)
        qc.cx(j,i)
        qc.cx(i,j)
    for i in range(0,n-1,2):
        swap(qc,i,i+1)
    for j in range(n-1-(n%2==0),1,-2):
        print(j,n)
        swap(qc,j,j-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> qt.QuantumCircuit:
    qc = qt.QuantumCircuit(n)
    # Write your code here:
    def sw(qc,i,j):
        qc.cx(i,j)
        qc.cx(j,i)
        qc.cx(i,j)
    for i in range(0,n-1,2):
        sw(qc,i,i+1)
    for j in range(n-1-(n%2==0),1,-2):
        sw(qc,j,j-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def sw(qc,i,j):
        qc.cx(i,j)
        qc.cx(j,i)
        qc.cx(i,j)
    for i in range(0,n-1,2):
        sw(qc,i,i+1)
    for j in range(n-1-(n%2==0),1,-2):
        sw(qc,j,j-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n - 1)):
        qc.cx(i,i+1)
        qc.cx(i+1,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n-2, -1, -1):
        qc.cx(i, i+1)
        qc.cx(i+1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    rest = [*range(n)]
    while rest:
        newrest = []
        for i in range(len(rest)//2):
            a = rest[2*i]
            b = rest[2*i+1]
            rest.append(b)
            swap(qc, a, b)
        rest = newrest
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    rest = [*range(n)]
    while rest:
        newrest = []
        for i in range(len(rest)//2):
            a = rest[2*i]
            b = rest[2*i+1]
            newrest.append(b)
            swap(qc, a, b)
        rest = newrest
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    rest = [*range(n)]
    while len(rest) != 1:
        newrest = []
        for i in range(len(rest)//2):
            a = rest[2*i]
            b = rest[2*i+1]
            newrest.append(b)
            swap(qc, a, b)
        if len(rest)%2 == 1:
            newrest.append(rest[-1])
        rest = newrest
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    now = [*range(n)]
    ans = [n-1] + [*range(n-1)]
    while now != ans:
        t = -1
        for i in range(n):
            if now[i] != ans[i]:
                if t != -1:
                    swap(qc, t, i)
                    now[t],now[i] = now[i],now[t]
                else:
                    t = i
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    now = [*range(n)]
    ans = [n-1] + [*range(n-1)]
    f = 1
    while now != ans:
        t = -1
        for i in range(n)[::-1*f]:
            if now[i] != ans[i]:
                if t != -1:
                    swap(qc, t, i)
                    now[t],now[i] = now[i],now[t]
                else:
                    t = i
        f *= -1

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def swap(qc, a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    now = [*range(n)]
    ans = [n-1] + [*range(n-1)]
    f = 1
    while now != ans:
        t = -1
        if f:
            for i in range(n):
                if now[i] != ans[i]:
                    if t != -1:
                        swap(qc, t, i)
                        now[t],now[i] = now[i],now[t]
                    else:
                        t = i
        else:
             for i in range(n-1,-1,-1):
                if now[i] != ans[i]:
                    if t != -1:
                        swap(qc, t, i)
                        now[t],now[i] = now[i],now[t]
                    else:
                        t = i
        f ^= 1

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.measure(n-1, 0)
    for i in reversed(range(n - 1)):
        qc.cx(i, i+1).c_if(0, 1)
        qc.cx(i+1, i).c_if(0, 1)
        qc.cx(i, i+1).c_if(0, 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector
from qiskit.visualization import *

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.measure(n-1, 0)
    for i in reversed(range(n - 1)):
        qc.cx(i, i+1).c_if(0, 1)
        qc.cx(i+1, i).c_if(0, 1)
        qc.cx(i, i+1).c_if(0, 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.measure(n-1, 0)
    for i in reversed(range(n - 1)):
        qc.cx(i, i+1).c_if(0, 1)
        qc.cx(i+1, i).c_if(0, 1)
        qc.cx(i, i+1).c_if(0, 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap3(qc: QuantumCircuit, q1: int, q2: int):
    """
    QiskitのSwapGateは禁止なので、
    SWAP(q1,q2) を CNOT×3 に手動分解する。
      - CNOT(q1->q2)
      - CNOT(q2->q1)
      - CNOT(q1->q2)
    """
    qc.cx(q1, q2)
    qc.cx(q2, q1)
    qc.cx(q1, q2)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # リング上の辺 E_i = (i, i-1 mod n)
    # Layer0: i even
    # Layer1: i odd
    layer0 = []
    layer1 = []
    for i in range(n):
        e = (i, (i - 1) % n)
        if i % 2 == 0:
            layer0.append(e)
        else:
            layer1.append(e)

    # --- 第1層: 偶数 i の辺を並列SWAP ---
    for (s, t) in layer0:
        swap3(qc, s, t)

    # --- 第2層: 奇数 i の辺を並列SWAP ---
    for (s, t) in layer1:
        swap3(qc, s, t)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap_adj(qc: QuantumCircuit, i: int, j: int):
    """
    隣接SWAPを CNOT×3 で分解。
    ただし i+1 = j を想定している。
    """
    qc.cx(i, j)
    qc.cx(j, i)
    qc.cx(i, j)

def solve(n: int) -> QuantumCircuit:
    """
    入力状態 |x0 x1 ... x_{n-2} 0> を
    出力状態 |0 x0 x1 ... x_{n-2}> に写す回路を、
    SwapGate禁止＆深さ<=20 で実装する。
    """
    qc = QuantumCircuit(n)

    # 右端のビット(=qubit n-1)を先頭(=qubit 0)へバブル移動
    # それには (n-1) 回の「隣接SWAP(q[i], q[i+1])」が必要。
    # しかし単純に直列実行すると深さが 3*(n-1) になってしまう。
    #
    # 下記では “odd-evenトランスフォーム” の要領で、ペアが重ならないSWAPを
    # できるだけ同時並行に行い、深さを削減している。
    #
    # おおまかに:
    #   round 1: すべての偶数ペア (0,1), (2,3), (4,5),...
    #   round 2: すべての奇数ペア (1,2), (3,4), (5,6),...
    # を繰り返し、右端ビットを順次左へシフト。

    # ここでは “n-1” ステップを繰り返せば必ず最右ビットが先頭に来る
    # (実際はバブル移動しながら全体を右回転する)。
    # 各ステップは2サブラウンド(偶数ペアと奇数ペア)に分かれる。
    # 1サブラウンド内は並列実行できるので、SWAP分の深さが3だけ加わる。

    for step in range(n-1):
        # サブラウンド1: 偶数ペアのSWAPを並列に
        for i in range(0, n-1, 2):
            swap_adj(qc, i, i+1)
        # サブラウンド2: 奇数ペアのSWAPを並列に
        for i in range(1, n-1, 2):
            swap_adj(qc, i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in reversed(range(n - 1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n : int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    #隣と入れ替える
    for i in range(int(n/2)):
        qc.cx(2*i,2*i+1)
        qc.cx(2*i+1,2*i)
        qc.cx(2*i,2*i+1)
    if(n%2 == 0):
        n-=1

    for i in range(n-1,0,-2):
        qc.cx(i,i-2)
        qc.cx(i-2,i)
        qc.cx(i,i-2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for _ in reversed(range(n-1)):
        qc.cx(_,_+1)
        qc.cx(_+1,_)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n,1,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1,0,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(n - i - 2, n - i - 1)
        qc.cx(n - i - 1, n - i - 2)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
    qc.cx(n-1, i)
    qc.cx(i, n-1)
    qc.cx(n-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
        qc.cx(n-1, i)
        qc.cx(i, n-1)
        qc.cx(n-1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
        qc.cx(n-2-i, n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-2):
        qc.cx(n-2-i, n-1-i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-2):
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-2):
        qc.cx(i+1, i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
        qc.cx(i+1, i)
        qc.cx(i, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range (n-1):
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(2*n-1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n-1)):
        qc.cx(i, i+1)
        qc.cx(i+1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n//2):
        qc.cx(i, n - 1 - i)
        qc.cx(n - 1 - i, i)
        qc.cx(i, n - 1 - i)
    for i in range(1, n//2 + n%2):
        qc.cx(i, n - i)
        qc.cx(n - i, i)
        qc.cx(i, n - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1):
        qc.cx(n-i-2, n-i-1)
        qc.cx(n-i-1, n-i-2)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.x(i)

    for i in range(n-2, 0, -1):
        qc.ccx(n-1, i-1, i)
        qc.ccx(n-1, i, i-1)
        qc.ccx(n-1, i-1, i)

    # 0が1でn-1が0の時だけ交換
    qc.x(n-1)         # n-1を反転（0→1, 1→0）
    qc.cx(0, n-1)    # 0が1ならn-1を反転
    qc.cx(n-1, 0)    # n-1が1なら0を反転
    qc.x(n-1)         # n-1を元に戻す

    for i in range(n):
        qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1):
        j = n-1-i
        k = n-2-i
        qc.cx(k,j)
        qc.cx(j,k)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def cnot_swap(qc, q1, q2):
        qc.cx(q1, q2)
        qc.cx(q2, q1)
        qc.cx(q1, q2)

    for i in range(n-1):
        cnot_swap(qc, 0, i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def cnot_swap(qc, q1, q2):
        qc.cx(q2, q1)
        qc.cx(q1, q2)

    for i in range(n-1):
        cnot_swap(qc, 0, i+1)

    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1):
        qc.h(n-i-2)
        qc.cx(n-i-2, n-i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    def swap(a,b):
    	qc.cx(a,b)
    	qc.cx(b,a)

    for i in range(n-1)[::-1]:
    	swap(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit, QuantumRegister
from math import pi, acos, sqrt, asin
from qiskit.circuit.library import XGate, ZGate

"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    def swap(a, b):
        qc.cx(a, b)
        qc.cx(b, a)
        qc.cx(a, b)

    # Write your code here:
    def cyc(L, R):
        if R - L == 1:
            return
        mid = (L + R) // 2
        swap(mid - 1, R - 1)
        cyc(L, mid)
        cyc(mid, R)

    cyc(0, n)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-1,0,-1):
        qc.cx(i-1,i)
        qc.cx(i,i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,-1,-1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i-1, i)
        qc.cx(i, i-1)
        #qc.cx(i-1, i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in reversed(range(n - 1)):
        qc.cx(i, i + 1)
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i, i + 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n - 1):
        qc.cx(i, i + 1)

    qc.cx(n - 1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.cx(i, i + 1)

    qc.cx(n - 1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-2):
        qc.cx(i, i + 1)

    qc.cx(n - 1, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n-1, 0, -1):
        qc.cx(i, i-1)
        qc.cx(i-1, i)
        qc.cx(i, i-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def tdswap(QC,qi):#qi=0~n-2
        qc.cx(qi+1,qi)
        qc.cx(qi,qi+1)

    for i in range(0,n-1):
        tdswap(qc,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def tdswap(QC,qi):#qi=0~n-2
        qc.cx(qi+1,qi)
        qc.cx(qi,qi+1)

    for i in range(n-2,-1, -1):
        tdswap(qc,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def tdswap(QC,qi):#qi=0~n-2
        qc.cx(qi,qi+1)
        qc.cx(qi+1,qi)

    for i in range(0,n-1):
        tdswap(qc,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    def tdswap(QC,qi):#qi=0~n-2
        qc.cx(qi,qi+1)
        qc.cx(qi+1,qi)

    for i in range(n-2,-1,-1):
        tdswap(qc,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h(n - 1)
    for i in range(n - 2, -1, -1):
        qc.cx(i + 1, i)
        qc.cx(i, i + 1)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2, -1, -1):
        qc.cx(i+1,i)
        qc.cx(i,i+1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2, -1, -1):
        qc.cx(i,i+1)
        qc.cx(i+1,i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in reversed(range(n-1)):
        i_first=i
        i_second=(i+1) % n
        qc.cx(i_first, i_second)
        qc.cx(i_second, i_first)
        qc.cx(i_first, i_second)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in reversed(range(n-1)):
        i_first=i
        i_second=(i+1) % n
        qc.cx(i_first, i_second)
        qc.cx(i_second, i_first)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n - 1):
        index = n - i - 1
        qc.cx(index - 1, index)
        qc.cx(index, index - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap(qc: QuantumCircuit, a: int, b: int) -> None:
    qc.cx(a, b)
    qc.cx(b, a)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n - 1, 0, -1):
        swap(qc, i, i - 1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def swap(qc: QuantumCircuit, a: int, b: int) -> None:
    qc.cx(a, b)
    qc.cx(b, a)

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n - 1, 0, -1):
        swap(qc, i - 1, i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    for i in range(n-2,-1,-1):
        qc.iswap(i,i+1)

    return qc
'''