from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from numpy import pi

qreg_q = QuantumRegister(9, 'q')
creg_c = ClassicalRegister(9, 'c')
circuit = QuantumCircuit(qreg_q, creg_c)

circuit.h(qreg_q[0])
circuit.h(qreg_q[1])
circuit.cx(qreg_q[0], qreg_q[2])
circuit.id(qreg_q[0])
circuit.x(qreg_q[2])
circuit.x(qreg_q[3])
circuit.cx(qreg_q[1], qreg_q[3])
circuit.id(qreg_q[1])
circuit.id(qreg_q[3])
circuit.x(qreg_q[3])
circuit.id(qreg_q[4])
circuit.id(qreg_q[4])
circuit.id(qreg_q[4])
circuit.x(qreg_q[4])
circuit.id(qreg_q[5])
circuit.id(qreg_q[5])
circuit.id(qreg_q[5])
circuit.id(qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.ccx(qreg_q[3], qreg_q[4], qreg_q[5])
circuit.x(qreg_q[4])
circuit.x(qreg_q[5])
circuit.id(qreg_q[6])
circuit.id(qreg_q[6])
circuit.id(qreg_q[6])
circuit.x(qreg_q[6])
circuit.x(qreg_q[6])
circuit.x(qreg_q[6])
circuit.x(qreg_q[6])
circuit.ccx(qreg_q[4], qreg_q[5], qreg_q[6])
circuit.ccx(qreg_q[6], qreg_q[7], qreg_q[8])
circuit.x(qreg_q[8])
circuit.measure(qreg_q[1], creg_c[1])
circuit.measure(qreg_q[2], creg_c[2])
circuit.measure(qreg_q[3], creg_c[3])
circuit.measure(qreg_q[4], creg_c[4])
circuit.measure(qreg_q[5], creg_c[5])
circuit.measure(qreg_q[6], creg_c[6])
circuit.measure(qreg_q[7], creg_c[7])
circuit.measure(qreg_q[8], creg_c[8])
