'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(-theta * math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta * math.pi, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(-2 * theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(0, theta)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rz(-2 * theta)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rz(-2 * theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2 * theta,0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.global_phase = theta
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.p(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rz(-theta*2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.p(qubit=0, theta=theta)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta,0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta,0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta)
    qc.rz(theta)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    if theta != 0:
        qc.ry(theta)
        qc.rz(theta)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2*theta)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(theta)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta, 0)
    qc.rz(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta, 0)
    qc.rx(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta, 0)
    qc.rx(math.pi, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(2*theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(0, theta)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    qc.x(0)
    qc.u(0, 0, theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rx(-2*theta)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rx(-2*thet, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rx(-2*theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.p(theta)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta,0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(2*theta, 0)
    qc.x()
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(2*theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.rx(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:

    qc.p(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

# generte the quantum circuit that prepares the state |ψ⟩ = cos(θ/2)|0⟩ + sin(θ/2)|1⟩
def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.p(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)

    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Apply the Rz gate to the qubit
    qc.rz(theta, 0)  # Apply Rz gate with angle theta to qubit 0
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta / 2, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(-theta/2, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.rz(theta, 0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.rz(theta/2, 0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta/2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(2*theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.h(0)
    qc.rz(2*theta, 0)
    qc.h(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(PhaseGate(theta), [0])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(theta/2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta/2, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc = QuantumCircuit(1, global_phase=theta)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(theta,0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.global_phase = theta

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta,0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import GlobalPhaseGate
# import math
# from qiskit.quantum_info import Statevector

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(GlobalPhaseGate(theta))
    return qc

# if __name__ == "__main__":
#     qc = solve(math.pi/2)
#     print(Statevector(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(-theta*2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta/2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.rz(theta*2, 0)
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(-theta * 2, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(theta, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.p(theta, 0)
    qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(theta)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.z(theta * 180 / math.pi)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta * 180 / math.p)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta * 180 / math.pi)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta *  math.pi / 180, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rx(theta *  math.pi / 180, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.ry(theta *  math.pi / 180, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.p(theta *  math.pi / 180, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.r(theta *  math.pi / 180)
    return qc
'''


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

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.rz(theta *  np.pi / 180, 0)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.append(RZGate(theta))
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.x(0)
    qc.append(RZGate(theta),[0])
    qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(1)
    # Write your code here:
    qc.append(RZGate((-2)*theta),[0])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)
    if n == 1:
        qc.p(theta, n - 1)
    else:
        qc.append(PhaseGate(theta).control(n - 1), range(n))

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)
    if n == 1:
        qc.p(theta, n - 1)
    else:
        qc.append(PhaseGate(theta).control(n - 1), range(n))

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    for i in range(n):
        qc.p(theta,i)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.rx(2*theta)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.rx(2*theta,0)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.rx(-2*theta,0)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(n,theta)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(theta)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(theta,range(n),n)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(theta,range(n-1),n-1)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(theta,tuple(range(n-1)),n-1)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    qc.mcp(theta,list(range(n-1)),n-1)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    if n == 1:
        qc.p(theta,0)
    else:
        qc.mcp(theta,lis(range(n-1)),n-1)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    if n == 1:
        qc.p(theta,0)
    else:
        qc.mcp(theta,list(range(n-1)),n-1)

    for i in range(n):
        if L >> i & 1 == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import U1Gate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        if ~L >> i & 1:
            qc.x(i)

    qc.append(U1Gate(theta).control(n-1), list(range(n)))

    for i in range(n):
        if ~L >> i & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import U1Gate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        if ~L >> i & 1:
            qc.x(i)

    if n == 1:
        qc.append(U1Gate(theta), list(range(n)))
    else:
        qc.append(U1Gate(theta).control(n-1), list(range(n)))

    for i in range(n):
        if ~L >> i & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    for i in range(n):
        if (L >> i & 1) == 0:
            qc.x(i)
    if n == 1:
        qc.p(theta, 0)
    else:
        qc.mcp(theta, list(range(n - 1)), n - 1)
    for i in range(n):
        if (L >> i & 1) == 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Convert L to its binary representation (little-endian)
    L_binary = format(L, f'0{n}b')[::-1]

    # Apply X gates to qubits that should be in |0⟩ state
    for i in range(n):
        if L_binary[i] == '0':
            qc.x(i)

    # Apply multi-controlled phase gate
    qc.mcphase(theta, [i for i in range(n)])

    # Apply X gates again to restore the original state
    for i in range(n):
        if L_binary[i] == '0':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from math import pi

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Convert L to binary and get its bit representation
    # Note: The default little-endian encoding will work directly with bin(L)[2:]
    binary_L = bin(L)[2:].zfill(n)

    # Create a list to store the qubits involved in the phase gate
    phase_qubits = []

    for i, bit in enumerate(reversed(binary_L)):
        if bit == '1':
            phase_qubits.append(i)

    # Apply the phase gate to the target qubits
    if phase_qubits:
        qc.p(theta, phase_qubits[0])
        for i in range(1, len(phase_qubits)):
            qc.cp(theta, phase_qubits[i], phase_qubits[0])

    return qc
'''


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

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    # Convert L to its binary representation
    L_bin = [int(b) for b in format(L, f'0{n}b')]

    # Apply phase shift e^{iθ} to the state |L⟩
    for qubit in range(n):
        if L_bin[qubit] == 1:
            qc.x(qubit)  # Flip qubit to make the controlled phase gate apply

    # Apply the phase shift to all qubits
    qc.rz(theta, range(n))  # Apply phase shift Rz(theta) to all qubits

    # Flip qubits back to their original state
    for qubit in range(n):
        if L_bin[qubit] == 1:
            qc.x(qubit)  # Flip qubit back

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    ii = [i for i in range(n) if (L >> i) & 1 == 0]

    qc.x(ii)
    qc.mcp(theta, list(range(1, n)), 0)
    qc.x(ii)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    ii = [i for i in range(n) if (L >> i) & 1 == 0]

    ii and qc.x(ii)
    qc.mcp(theta, list(range(1, n)), 0)
    ii and qc.x(ii)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    ii = [i for i in range(n) if (L >> i) & 1 == 0]

    ii and qc.x(ii)
    if n == 1:
        qc.p(theta, 0)
    else:
        qc.mcp(theta, list(range(1, n)), 0)
    ii and qc.x(ii)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(n)[2:]
    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1
    qc.rz(theta, 0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(n)[2:]
    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1
    if n>1:
        qc.rz(theta, 0).control(len(binary)-1)
    else:
        qc.rz(theta, 0)

    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(n)[2:]
    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(len(binary)-1)
    qc.append(qcz, list(range(n)))

    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:]
    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    i=0
    for bit in binary:
        if bit=="1":
            qc.x(i)
        i=i+1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:]
    i=0
    for bit in binary:
        if bit=="0":
            qc.x(i)
        i=i+1

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    i=0
    for bit in binary:
        if bit=="0":
            qc.x(i)
        i=i+1

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:]
    for bit in range(n):
        if binary(bit)=="1":
            qc.x(bit)

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    for bit in range(n):
        if binary(bit)=="1":
            qc.x(bit)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:].zfill(n)
    for bit in range(n):
        if binary[bit]=="1":
            qc.x(bit)

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    for bit in range(n):
        if binary[bit]=="1":
            qc.x(bit)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:].zfill(n)
    for bit in range(n):
        if binary[bit]=="0":
            qc.x(bit)

    qcz = QuantumCircuit(1)
    qcz.rz(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    for bit in range(n):
        if binary[bit]=="0":
            qc.x(bit)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:].zfill(n)
    for bit in range(n):
        if binary[bit]=="1":
            qc.x(bit)

    qcz = QuantumCircuit(1)
    qcz.p(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    for bit in range(n):
        if binary[bit]=="1":
            qc.x(bit)

    return qc
'''


'''python
from qiskit import QuantumCircuit
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    binary=bin(L)[2:].zfill(n)
    for bit in range(n):
        if binary[bit]=="0":
            qc.x(bit)

    qcz = QuantumCircuit(1)
    qcz.p(theta, 0)
    if n>1:
        qcz=qcz.to_gate().control(n-1)
    qc.append(qcz, list(range(n)))

    for bit in range(n):
        if binary[bit]=="0":
            qc.x(bit)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(QuantumRegister(n))
    # Write your code here:
    qc.append(PhaseGate(theta).control(n-1),QuantumRegister(n))
    for i in range(n):
        if (L>>i)%2==0:
            qc.append(XGate(i))
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import PhaseGate
from qiskit.circuit.library.standard_gates import XGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.append(PhaseGate(theta).control(n-1),QuantumRegister(n))
    for i in range(n):
        if (L>>i)%2==0:
            qc.append(XGate(i))
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit.circuit.library.standard_gates import PhaseGate
from qiskit.circuit.library.standard_gates import XGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.append(PhaseGate(theta).control(n-1),QuantumRegister(n))
    for i in range(n):
        if (L>>i)%2==0:
            qc.append(XGate(i))
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit.circuit.library.standard_gates import PhaseGate
from qiskit.circuit.library.standard_gates import XGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qr1 = QuantumRegister(n)
    qc1 = QuantumCircuit(qr1)
    # Write your code here:
    qc1.append(PhaseGate(theta).control(n-1),qr1)

    qr2 = QuantumRegister(n)
    qc2 = QuantumCircuit(qr2)
    for i in range(n):
        if (L>>i)%2==0:
            qc2.x(i)

    qc1.append(qc2.to_gate(),qr1)

    return qc1
'''


'''python
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit.circuit.library import MCPhaseGate
from qiskit.circuit.library.standard_gates import XGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qr1 = QuantumRegister(n)
    qc1 = QuantumCircuit(qr1)
    # Write your code here:
    qc1.append(MCPhaseGate(theta,n-1),qr1)

    qr2 = QuantumRegister(n)
    qc2 = QuantumCircuit(qr2)
    for i in range(n):
        if (L>>i)%2==0:
            qc2.x(i)

    qc1.append(qc2.to_gate(),qr1)

    return qc1
'''


'''python
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit.circuit.library.standard_gates import MCPhaseGate
from qiskit.circuit.library.standard_gates import XGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qr1 = QuantumRegister(n)
    qc1 = QuantumCircuit(qr1)
    # Write your code here:
    qc1.append(MCPhaseGate(theta,n-),qr1)

    qr2 = QuantumRegister(n)
    qc2 = QuantumCircuit(qr2)
    for i in range(n):
        if (L>>i)%2==0:
            qc2.x(i)

    qc1.append(qc2.to_gate(),qr1)

    return qc1
'''


'''python
from qiskit import QuantumCircuit
from qiskit import QuantumRegister
from qiskit.circuit.library.standard_gates import MCPhaseGate
from qiskit.circuit.library.standard_gates import XGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qr1 = QuantumRegister(n)
    qc1 = QuantumCircuit(qr1)
    # Write your code here:
    qc1.append(MCPhaseGate(theta,n-1),qr1)

    qr2 = QuantumRegister(n)
    qc2 = QuantumCircuit(qr2)
    for i in range(n):
        if (L>>i)%2==0:
            qc2.x(i)

    qc1.append(qc2.to_gate(),qr1)

    return qc1
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.cp(theta,range(n-1),n-1)
    for i in range(n):
        if (L>>i)%2==0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n==1:
        qc.p(theta,0)
        if L==0:
            qc.x(0)
        return qc
    qc.cp(theta,range(n-1),n-1)
    for i in range(n):
        if (L>>i)%2==0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n==1:
        qc.p(theta,0)
        if L==0:
            qc.x(0)
        return qc
    qc.cp(theta,control_qubit=range(n-1),target_qubit=n-1)
    for i in range(n):
        if (L>>i)%2==0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if(L =< n):
        for i in range(n):
            if (i = L):
                qc.p(theta,i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if(L =< n):
        for i in range(n):
            if (i = L):
                qc.p(theta,i-1)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')][::-1]

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(-2*theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')][::-1]

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')][::-1]

    qc.h(0)
    qc.h(1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

    qc.h(0)
    qc.h(1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

    qc.h(0)
    qc.h(1)

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')][::-1]

    qc.h(0)
    qc.h(1)

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')][::-1]

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

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i,bit in enumerate(bL):
        if bit == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bL = [int(b) for b in format(L, f'0{n}b')]

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

    for i in range(n):
        if bL[i] == 1:
            qc.cx(i, n-1)

    qc.rz(2*theta, n-1)

    for i in range(n):
        if bL[i] == 1:
            qc.cx(i, n-1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

    mcrz = MCRZGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcrz, list(range(n)))

    binary_str = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

    mcrz = MCRZGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcrz, list(range(n)))

    binary_str = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

    mcrz = MCRZGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcrz, list(range(n)))

    bit_array = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCRZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

    mcrz = MCRZGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcrz, list(range(n)))

    bit_array = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCRZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
      qc.h(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCRZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

    mcrz = MCRZGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcrz, list(range(n)))

    bit_array = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    bit_array = bin(L)[2:]

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    bit_array = bin(L)[2:]
    bit_array = list(binary_str)

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    bit_array = bin(L)[2:].zfill(n)
    bit_array = list(binary_str)

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    bit_array = bin(L)[2:].zfill(n)
    bit_array = list(binary_str)

    for i, bit in enumerate(bit_array):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
  qc.append(mcphase, list(range(n)))

  bit_array = bin(L)[2:].zfill(n)
  bit_array = list(binary_str)

  for i, bit in enumerate(reversed(bit_array)):
    if bit == '0':
      qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
  qc.append(mcphase, list(range(n)))

  binary_str = bin(L)[2:].zfill(n)
  bit_array = list(binary_str)

  for i, bit in enumerate(reversed(bit_array)):
    if bit == '0':
      qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  mcphase = MCPhaseGate(theta, num_ctrl_qubits = n-1)
  qc.append(mcphase, list(range(n)))

  binary_str = bin(L)[2:].zfill(n)
  bit_array = list(binary_str)

  for i, bit in enumerate(bit_array):
    if bit == '0':
      qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  mcphase = MCPhaseGate(theta, num_ctrl_qubits = n-1)
  qc.append(mcphase, list(range(n)))

  #binary_str = bin(L)[2:].zfill(n)
  #bit_array = list(binary_str)

  #for i, bit in enumerate(reversed(bit_array)):
  #  if bit == '0':
  #    qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  if(n==1):

  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits = n-1)
    qc.append(mcphase, list(range(n)))

    #binary_str = bin(L)[2:].zfill(n)
    #bit_array = list(binary_str)

    #for i, bit in enumerate(reversed(bit_array)):
    #  if bit == '0':
    #    qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  if n == 1 :

  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits = n-1)
    qc.append(mcphase, list(range(n)))

    #binary_str = bin(L)[2:].zfill(n)
    #bit_array = list(binary_str)

    #for i, bit in enumerate(reversed(bit_array)):
    #  if bit == '0':
    #    qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  if n == 1 :
    pass
  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits = n-1)
    qc.append(mcphase, list(range(n)))

    #binary_str = bin(L)[2:].zfill(n)
    #bit_array = list(binary_str)

    #for i, bit in enumerate(reversed(bit_array)):
    #  if bit == '0':
    #    qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  for i in range(n):
    qc.h(i)

  if n == 1 :
    pass
  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    binary_str = bin(L)[2:].zfill(n)
    bit_array = list(binary_str)

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  if n == 1 :
    pass
  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    binary_str = bin(L)[2:].zfill(n)
    bit_array = list(binary_str)

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
  qc = QuantumCircuit(n)
  # Write your code here:
  if n == 1 :
    pass
  else:
    binary_str = bin(L)[2:].zfill(n)
    bit_array = list(binary_str)

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

    for i, bit in enumerate(reversed(bit_array)):
      if bit == '0':
        qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import MCPhaseGate

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

  binary_str = bin(L)[2:].zfill(n)
  bit_array = list(binary_str)

  for i, bit in enumerate(reversed(bit_array)):
    if bit == '0':
      qc.x(i)

  if n == 1 :
    qc.rz(theta, 0)
  else:
    mcphase = MCPhaseGate(theta, num_ctrl_qubits=n-1)
    qc.append(mcphase, list(range(n)))

  for i, bit in enumerate(reversed(bit_array)):
    if bit == '0':
      qc.x(i)

  return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

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

    L_bin = bin(L)[2:].zfill(n)
    for i, bit in enumerate(L_bin):
        if bit == '0':
            qc.x(i)

    qc.append(PhaseGate(theta).control(n - 2), range(n - 1))

    for i, bit in enumerate(L_bin):
        if bit == '0':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

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

    L_bin = bin(L)[2:].zfill(n)
    for i, bit in enumerate(L_bin):
        if bit == '0':
            qc.x(i)

    qc.append(PhaseGate(theta).control(n - 1), range(n))

    for i, bit in enumerate(L_bin):
        if bit == '0':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

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

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    qc.append(PhaseGate(theta).control(n - 1), range(n))

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

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

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    if n == 1:
        qc.append(PhaseGate(theta), [0])
    else:
        qc.append(PhaseGate(theta).control(n - 1), range(n))

    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    flipnum = 0
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            flipnum += 1
            fliplist.append(i)
    qc.append(PhaseGate(theta).control(flipnum), fliplist)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    flipnum = 0
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            flipnum += 1
            fliplist.append(i)
    qc.append(PhaseGate(theta).control(flipnum), fliplist)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    qc.append(PhaseGate(theta).control(n), range(n))
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    qc.append(PhaseGate(theta).control(n), range(n)+0)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)] + [0]
    qc.append(PhaseGate(theta).control(n), )
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)] + [0]
    qc.append(PhaseGate(theta).control(n), list)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)] + [0]
    qc.append(PhaseGate(theta).control(n), lis)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)] + [0]
    qc.append(PhaseGate(theta).control(n), list)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)]
    qc.append(PhaseGate(theta).control(n - 1), list)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    fliplist = []
    for i in range(n):
        if ((L>>i)&1) == 0:
            qc.x(i)
            fliplist.append(i)
    list = [i for i in range(n)]
    if n == 1:
        qc.p(theta, 0)
    else:
        qc.append(PhaseGate(theta).control(n - 1), list)
    for idx in fliplist:
        qc.x(idx)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # Convert L to a binary string with n bits
    L_bin = format(L, f'0{n}b')

    # Apply X gates to qubits where L_bin is 0 (flips the basis)
    for i in range(n):
        if L_bin[i] == '0':
            qc.x(i)

    # Apply the multi-controlled phase gate
    # We use MCPhase to apply a controlled phase shift of e^(i * theta)
    qc.append(MCPhase(theta, num_ctrl_qubits=n-1), list(range(n)))

    # Reapply X gates to revert the basis to original
    for i in range(n):
        if L_bin[i] == '0':
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 # Apply Hadamard to the control qubits to create superposition
    for i in range(n - 1):
        qc.h(i)

    # Apply multi-controlled Toffoli gate (control on all qubits except target)
    if n > 1:
        # Create a multi-controlled Toffoli gate
        from qiskit.circuit.library import MCXGate
        mct = MCXGate(n - 1)

        # Apply multi-controlled Toffoli gate
        qc.append(mct, range(n - 1) + [target_qubit])

    # Apply a phase gate to introduce the phase of i
    # Phase i corresponds to a RZ rotation of pi/2 and then a RY rotation of -pi/2
    qc.rz(math.pi / 2, target_qubit)  # Phase shift by pi/2
    qc.ry(-math.pi / 2, target_qubit) # Phase shift by -pi/2
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    # Convert L to binary and apply X gates to the target qubit to flip it if L is set
    binary_L = [int(bit) for bit in format(L, f'0{n}b')]

    for i, bit in enumerate(binary_L):
        if bit == 1:
            qc.x(i)

    # Apply a multi-controlled Toffoli gate to flip the phase of the target qubit
    if n > 1:
        mct = MCXGate(n - 1)  # Multi-controlled Toffoli gate
        qc.append(mct, range(n) + [n])

    # Apply a phase shift of e^{iθ} to the target qubit
    qc.p(theta, n)  # Use phase gate to introduce the phase shift

    # Clean up: Apply X gates again to reverse the effect if necessary
    for i, bit in enumerate(binary_L):
        if bit == 1:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.p(theta, L)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h(range(n))
    qc.p(theta, L)
    qc.h(range(n))
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # Step 1: Apply X gates to flip the bits that are 0 in L to 1
    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    # Step 2: Apply a multi-controlled Rz gate to introduce the phase e^(iθ) to the state |L⟩
    qc.mcrz(theta, list(range(n)), 0)

    # Step 3: Apply X gates again to revert the changes made by the first set of X gates
    for i in range(n):
        if not (L >> i) & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    # Step 1: Apply X gates to match the bits of L
    for i in range(n):
        if (L >> i) & 1 == 0:  # If the i-th bit of L is 0, apply X to qubit i
            qc.x(i)

    # Step 2: Apply a multi-controlled Rz gate (controlled on all n qubits)
    qc.mcrz(theta, list(range(n)), 0)

    # Step 3: Apply X gates again to revert the initial bit flips
    for i in range(n):
        if (L >> i) & 1 == 0:  # Revert the X gate applied earlier
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    bitstr = bin(L)[2:].zfill(n)[::-1]  # 2進数表記に変換して逆順にする

    last_bit = bitstr[-1]
    bitstr = bitstr[:-1]  # 最後のビットは制御ビットに使うので除外

    if last_bit == "1":
        qc.x(n - 1)
    qc.mcp(theta, list(range(n - 1)), n - 1, ctrl_state=bitstr)
    if last_bit == "1":
        qc.x(n - 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    if n >= 2:
        bitstr = bin(L)[2:].zfill(n)[::-1]  # 2進数表記に変換して逆順にする

        last_bit = bitstr[-1]
        bitstr = bitstr[:-1]  # 最後のビットは制御ビットに使うので除外

        if last_bit == "0":
            qc.x(n - 1)
        qc.mcp(theta, list(range(n - 1)), n - 1, ctrl_state=bitstr)
        if last_bit == "0":
            qc.x(n - 1)
    else:
        if L == 0:
            qc.x(0)
        qc.p(theta, 0)
        if L == 0:
            qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    if n >= 2:
        bitstr = bin(L)[2:].zfill(n)  # 2進数表記に変換して逆順にする

        last_bit = bitstr[-1]
        bitstr = bitstr[:-1]  # 最後のビットは制御ビットに使うので除外

        if last_bit == "1":
            qc.x(n - 1)
        qc.mcp(theta, list(range(n - 1)), n - 1, ctrl_state=bitstr)
        if last_bit == "1":
            qc.x(n - 1)
    else:
        if L == 0:
            qc.x(0)
        qc.p(theta, 0)
        if L == 0:
            qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    if n >= 2:
        bitstr = bin(L)[2:].zfill(n)[::-1]  # 2進数表記に変換して逆順にする

        last_bit = bitstr[-1]
        bitstr = bitstr[:-1]  # 最後のビットは制御ビットに使うので除外

        if last_bit == "1":
            qc.x(n - 1)
        qc.mcp(theta, list(range(n - 1)), n - 1, ctrl_state=bitstr)
        if last_bit == "1":
            qc.x(n - 1)
    else:
        if L == 0:
            qc.x(0)
        qc.p(theta, 0)
        if L == 0:
            qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    if n >= 2:
        full_bitstr = bin(L)[2:].zfill(n)[::-1]  # 2進数表記に変換して逆順にする

        for i, b in enumerate(full_bitstr):
            if b == "0":
                qc.x(i)
        qc.mcp(theta, list(range(n - 1)), n - 1)
        for i, b in enumerate(full_bitstr):
            if b == "0":
                qc.x(i)
    else:
        if L == 0:
            qc.x(0)
        qc.p(theta, 0)
        if L == 0:
            qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    qc.mcp(list(range(n)), 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    qc.mcp(theta, list(range(n)), 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    qc.mcp(theta,list(range(1,n)), 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    #qc.mcp(theta, list(range(1,n)), 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    #qc.mcp(theta, list(range(1,n)), 0)
    qc.mcp(theta, [0,1,2],3)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    #qc.mcp(theta, list(range(1,n)), 0)
    qc.mcp(theta, [0],1)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    if n > 1:
        qc.mcp(theta, list(range(1,n)), 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    if n > 1:
        qc.mcp(theta, list(range(1,n)), 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        qc.h(i)

    if n > 1:
        qc.mcp(theta, list(range(1,n)), 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if L & (1<<(n-1-i)) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    if n > 1:
        qc.mcp(theta, list(range(1,n)), 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)

    if n > 1:
        qc.mcp(theta, list(range(1,n)), 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if L & (1<<i) == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0[n]b}"]

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    qc.mcp(theta, list(range(1, n)), 0)

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    qc.mcp(theta, list(range(1, n)), 0)

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]
    bits.reverse()

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    qc.mcp(theta, list(range(1, n)), 0)

    if bits[0] == 0:
        qc.x(0)

    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)

    return qc
'''


'''python
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]
    bits.reverse()

    if bits[0] == 0:
        qc.x(0)

    if n > 1:
        for i, b in enumerate(bits[1:]):
            if b == 0:
                qc.x(i + 1)

        qc.mcp(theta, list(range(1, n)), 0)

        for i, b in enumerate(bits[1:]):
            if b == 0:
                qc.x(i + 1)
    else:
        qc.p(theta, 0)

    if bits[0] == 0:
        qc.x(0)

    return qc
'''


'''python
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]
    bits.reverse()
    if bits[0] == 0:
        qc.x(0)
    if n > 1:
        for i, b in enumerate(bits[1:]):
            if b == 0:
                qc.x(i + 1)
        qc.mcp(theta, list(range(1, n)), 0)
        for i, b in enumerate(bits[1:]):
            if b == 0:
                qc.x(i + 1)
    else:
        qc.p(theta, 0)
    if bits[0] == 0:
        qc.x(0)
    return qc
'''


'''python
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]
    bits.reverse()
    if bits[0] == 0:
        qc.x(0)
    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)
    if n > 1:
        qc.mcp(theta, list(range(1, n)), 0)
    else:
        qc.p(theta, 0)
    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)
    if bits[0] == 0:
        qc.x(0)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bits = [int(x) for x in f"{L:0{n}b}"]
    bits.reverse()
    if bits[0] == 0:
        qc.x(0)
    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)
    if n > 1:
        qc.mcp(theta, list(range(1, n)), 0)
    else:
        qc.p(theta, 0)
    for i, b in enumerate(bits[1:]):
        if b == 0:
            qc.x(i + 1)
    if bits[0] == 0:
        qc.x(0)
    return qc
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate, PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)
    qc.append(PhaseGate(theta).control(n - 1), range(n))
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)

    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     qc = solve(0.5)
#     sv = Statevector(qc)
#     print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
# #     sv = Statevector.from_label('+++')
# #     print(sv.evolve(qc))
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate, PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)
    if n == 1:
        qc.append(PhaseGate(theta))
    else:
        qc.append(PhaseGate(theta).control(n - 1), range(n))
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)

    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     qc = solve(2, 1, math.pi / 2)
#     # sv = Statevector(qc)
#     # print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
#     sv = Statevector.from_label('++')
#     print(sv.evolve(qc))
'''


'''python
import math
from qiskit import QuantumCircuit
from qiskit.circuit.library import ZGate, PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)
    if n == 1:
        qc.append(PhaseGate(theta), range(n))
    else:
        qc.append(PhaseGate(theta).control(n - 1), range(n))
    for i in range(n):
        if not (L & (1 << i)):
            qc.x(i)

    return qc

# if __name__ == "__main__":
#     from qiskit.quantum_info import Statevector
#     import numpy as np
#     qc = solve(2, 1, math.pi / 2)
#     # sv = Statevector(qc)
#     # print(sv)
#     print(qc)
#     print(f"{qc.depth() = }")
#     sv = Statevector.from_label('++')
#     print(sv.evolve(qc))
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:

    bin_L = format(L, '0' + str(n) + 'b')

    for i in range(n):
        if bin_L[i] == '1':
            qc.x(i)

    qc.append(Gate(name='PHASE_SHIFT', num_qubits=n, params=[theta]), range(n))

    for i in range(n):
        if bin_L[i] == '1':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    bin_L = format(L, '0' + str(n) + 'b')

    for i in range(n):
        if bin_L[i] == '1':
            qc.x(i)

    qc.append(Gate(name='PHASE_SHIFT', num_qubits=n, params=[theta]), range(n))

    for i in range(n):
        if bin_L[i] == '1':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if (L >> i) & 1:
            qc.x(i)
    qc.p(theta, range(n))

    for i in range(n):
        if (L >> i) & 1:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if (L >> i) & 1:
            qc.x(i)
    qc.rz(theta, range(n))

    for i in range(n):
        if (L >> i) & 1:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if (L >> (n-1-i)) & 1:
            qc.x(i)
    qc.p(theta, range(n))

    for i in range(n):
        if (L >> (n-1-i)) & 1:
            qc.x(i)
    return qc
'''


'''python
rom qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if L>>i & 0:
            qc.x(i)

    if n == 1:
        qc.p(theta, n - 1)
    else:
        qc.mcp(theta, list(range(n - 1)), n - 1)

    for i in range(n):
        if L>>i & 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if L>>i & 0:
            qc.x(i)

    if n == 1:
        qc.p(theta, n - 1)
    else:
        qc.mcp(theta, list(range(n - 1)), n - 1)

    for i in range(n):
        if L>>i & 0:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)

    for i in range(n):
        if not L>>i & 1:
            qc.x(i)

    if n == 1:
        qc.p(theta, n - 1)
    else:
        qc.mcp(theta, list(range(n - 1)), n - 1)

    for i in range(n):
        if not L>>i & 1:
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if not (L>>i)&1:
            qc.x(i)

    if n==1:
        qc.p(theta, 0)
    else:
        qc.mcp(theta, list(range(n-1)), n-1)

    for i in range(n):
            if not (L>>i)&1:
                qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
     # Convert L to binary and reverse it because of little-endian encoding
    L_bin = format(L, f'0{n}b')[::-1]

    # Find the control qubits (qubits that must be in the |1> state)
    control_qubits = [i for i in range(n) if L_bin[i] == '1']

    # Apply the multi-controlled phase shift gate
    if control_qubits:
        qc.mcp(theta, control_qubits, qc.qubits[0])

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Convert L to binary
    L_bin = format(L, f'0{n}b')[::-1]

    # Apply X gates to invert the necessary qubits to prepare for multi-controlled phase
    for i in range(n):
        if L_bin[i] == '0':
            qc.x(i)

    # Apply multi-controlled Z gate with phase theta
    qc.mcp(theta, list(range(1, n)), 0)  # Apply the phase with n-1 controls

    # Reverse the X gates to clean up
    for i in range(n):
        if L_bin[i] == '0':
            qc.x(i)

    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    #for i in range(n):
    #   qc.h(i)

    binary = bin(L)
    ctrl_state = binary[-1:1:-1]

    print(ctrl_state)

    ctrl_state = ctrl_state + (n - len(ctrl_state))*'0'
    print(ctrl_state)

    print(ctrl_state[0])

    if n > 1:

        if ctrl_state[0] == '0':
            ctrl_state = ctrl_state[-1:0:-1]
            print(ctrl_state)
            qc.x(0)
            qc.mcp(theta, control_qubits= [i for i in range(1,n)] , ctrl_state = ctrl_state,target_qubit= 0)
            qc.x(0)

        else :
            ctrl_state = ctrl_state[-1:0:-1]
            print(ctrl_state)
            qc.mcp(theta, control_qubits= [i for i in range(1,n)] , ctrl_state = ctrl_state,target_qubit= 0)

    #qc.measure_all()
    else :
        if L == 0:
            qc.x(0)
        qc.p(theta , 0)
        if L == 0:
            qc.x(0)

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import U1Gate

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

    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h([i for i in range(n)])

    bin_num = format(L,'b').zfill(n)[::-1]
    Up = PhaseGate(theta).control(n-1)

    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    qc.append(Up, [i for i in range(n)])
    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h([i for i in range(n)])

    bin_num = format(L,'b').zfill(n)#[::-1]
    Up = PhaseGate(theta).control(n-1)

    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    qc.append(Up, [i for i in range(n)])
    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates.p import MCPhaseGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h([i for i in range(n)])

    bin_num = format(L,'b').zfill(n)[::-1]
    Up = PhaseGate(theta).control(n-1)

    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    qc.append(Up, [i for i in range(n)])
    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates.p import MCPhaseGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h([i for i in range(n)])

    bin_num = format(L,'b').zfill(n)[::-1]
    Up = MCPhaseGate(lam=theta, num_ctrl_qubits=n-1)

    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    qc.append(Up, [i for i in range(n)])
    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates.p import MCPhaseGate
import math

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    qc.h([i for i in range(n)])

    bin_num = format(L,'b').zfill(n)#[::-1]
    Up = MCPhaseGate(lam=theta, num_ctrl_qubits=n-1)

    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    qc.append(Up, [i for i in range(n)])
    for i in range(n):
        if bin_num[i] == '0':
            qc.x([i])
        else:
            pass
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bin_L=format(L, f'0{n}b')
    target_qubits=[i for i in range(n)]
    for i, bit in enumerate(reversed(bin_L)):
        if bit=='1':
            qc.x(i)
    qc.p(theta,0)
    for i,bit in enumerate(reversed(bin_L)):
        if bit=='1':
            qc.x(I)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    bin_L=format(L, f'0{n}b')
    target_qubits=[i for i in range(n)]
    for i, bit in enumerate(reversed(bin_L)):
        if bit=='1':
            qc.x(i)
    qc.p(theta,[i for i in range(n)])
    for i,bit in enumerate(reversed(bin_L)):
        if bit=='1':
            qc.x(I)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    ctls = []
    current_index = 0
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index += 1

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    ctls = []
    current_index = 0
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index += 1
        L/=2

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

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

    ctls = []
    current_index = n-1
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index -= 1
        L/=2

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

from math import floor
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    ctls = []
    current_index = n-1
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index -= 1
        L/=2
        L = floor(L)

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

from math import floo
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    ctls = []
    current_index = 0
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index += 1
        L/=2
        L = floor(L)

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

from math import floor
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    ctls = []
    current_index = 0
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index += 1
        L/=2
        L = floor(L)

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

from math import floor
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    ctls = []
    current_index = n-1
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index -= 1
        L/=2
        L = floor(L)

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    if n == 1:
        qc.p(theta, 0)
    else:
        qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

from math import floor
def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:

    ctls = []
    current_index = 0
    while L > 0:
        if  L % 2 == 1:
            ctls.append(current_index)
        current_index += 1
        L/=2
        L = floor(L)

    for i in range(n):
        if i not in ctls:
            qc.x(i)

    if n == 1:
        qc.p(theta, 0)
    else:
        qc.mcp(theta, [i for i in range(1, n)], 0)
    for i in range(n):
        if i not in ctls:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** n)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    qc.append(PhaseGate(-2 * theta).control(3), [n - _ - 1 for _ in range(n)])

    for i in range(n):
        if (L // (2 ** n)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** n)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    qc.append(PhaseGate(-2 * theta).control(3), [_ for _ in range(n)])
    qc.x(0)

    for i in range(n):
        if (L // (2 ** n)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import PhaseGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    qc.append(PhaseGate(-2 * theta).control(3), [_ for _ in range(n)])
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    qc.mcp(-2 * theta, [_ for _ in range(1, n)], 0)
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(n - i - 1)

    qc.x(0)
    qc.mcp(-2 * theta, [_ for _ in range(1, n)], 0)
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(n - 1 - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(n - i - 1)

    qc.x(0)
    qc.append(RZGate(-2 * theta).control(n - 1), [n-1-_ for _ in range(n)])
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(n - 1 - i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    qc.append(RZGate(-2 * theta).control(n - 1), [n-1-_ for _ in range(n)])
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    qc.x(0)
    if n > 1:
        qc.append(RZGate(-2 * theta).control(n - 1), [n-1-_ for _ in range(n)])
    else:
        qc.rz(-2 * theta, 0)
    qc.x(0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    if n > 1:
        qc.mcp(theta, [_ for _ in range(1, n)], 0)
    else:
        qc.p(theta)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)

    if n > 1:
        qc.mcp(theta, [_ for _ in range(1, n)], 0)
    else:
        qc.p(theta, 0)

    for i in range(n):
        if (L // (2 ** i)) % 2 == 0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
            qc.crx(-2*theta, i, i)
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)

    qc.append(RZGate(-2*theta).control(n - 1), range(n))

    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)

    qc.append(RZGate(-2*thet).control(n - 1), range(n))

    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)

    qc.append(RZGate(-2*theta).control(n - 1), range(n))

    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
    if n==1:
        qc.rz(-2*theta, 0)
    else:
        qc.append(RZGate(-2*theta).control(n - 1), range(n))

    for i in range(n):
        if (L&(1<<i))!=0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if (L&(1<<i))==0:
            qc.x(i)
    if n==1:
        qc.rz(-2*theta, 0)
    else:
        qc.append(RZGate(-2*theta).control(n - 1), range(n))

    for i in range(n):
        if (L&(1<<i))==0:
            qc.x(i)
    return qc
'''


'''python
from qiskit import QuantumCircuit
from qiskit.circuit.library import RZGate

def solve(n: int, L: int, theta: float) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
    for i in range(n):
        if not ((l >> i) & 1):
            qc.x(i)
    if n==1:
        qc.rz(-2*theta, 0)
    else:
        qc.append(RZGate(-2*theta).control(n - 1), range(n))

    for i in range(n):
        if not ((l >> i) & 1):
            qc.x(i)
    return qc
'''