






import numpy as np
import qiskit







def 						a_      (__A							,					__A			)							->	qiskit.QuantumCircuit:



					"""simple docstring"""
					__a				:	Any			=				qiskit.QuantumCircuit(num_qubits + 1			)

					# First, let's deal with the case in which oracle is balanced
					if case == "balanced":
										# First generate a random number that tells us which CNOTs to
										# wrap in X-gates:
										__a				:	Tuple			=				np.random.randint(1							,					2**num_qubits			)
										# Next, format 'b' as a binary string of length 'n', padded with zeros:
										__a				:	Union[str, Any]			=				format(__A							,					f'0{num_qubits}b'			)
										# Next, we place the first X-gates. Each digit in our binary string
										# corresponds to a qubit, if the digit is 0, we do nothing, if it's 1
										# we apply an X-gate to that qubit:
										for index, bit in enumerate(__A			):
															if bit == "1":
																				oracle_qc.x(__A			)
        # Do the controlled-NOT gates for each qubit, using the output qubit
        # as the target:
										for index in range(__A			):
															oracle_qc.cx(__A							,					__A			)
										# Next, place the final X-gates
										for index, bit in enumerate(__A			):
															if bit == "1":
																				oracle_qc.x(__A			)

    # Case in which oracle is constant
					if case == "constant":
										# First decide what the fixed output of the oracle will be
										# (either always 0 or always 1)
										__a				:	List[str]			=				np.random.randint(2			)
										if output == 1:
															oracle_qc.x(__A			)

					__a				:	List[Any]			=				oracle_qc.to_gate()
					__a				:	Union[str, Any]			=				"Oracle"  # To show when we display the circuit
					return oracle_gate







def 						a_      (__A							,					__A			)							->	qiskit.QuantumCircuit:



					"""simple docstring"""
					__a				:	List[str]			=				qiskit.QuantumCircuit(num_qubits + 1							,					__A			)
					# Set up the output qubit:
					dj_circuit.x(__A			)
					dj_circuit.h(__A			)
					# And set up the input register:
					for qubit in range(__A			):
										dj_circuit.h(__A			)
					# Let's append the oracle gate to our circuit:
					dj_circuit.append(__A							,					range(num_qubits + 1			)			)
					# Finally, perform the H-gates again and measure:
					for qubit in range(__A			):
										dj_circuit.h(__A			)

					for i in range(__A			):
										dj_circuit.measure(__A							,					__A			)

					return dj_circuit







def 						a_      (__A							,					__A			)							->	qiskit.result.counts.Counts:



					"""simple docstring"""
					__a				:	Union[str, Any]			=				qiskit.Aer.get_backend("aer_simulator"			)

					__a				:	int			=				dj_oracle(__A							,					__A			)
					__a				:	Optional[int]			=				dj_algorithm(__A							,					__A			)

					# Execute the circuit on the simulator
					__a				:	Union[str, Any]			=				qiskit.execute(__A							,					__A							,					shots=1_000			)

					# Return the histogram data of the results of the experiment.
					return job.result().get_counts(__A			)


if __name__ == "__main__":
		print(F"Deutsch Jozsa - Constant Oracle: {deutsch_jozsa('constant', 3)}")
		print(F"Deutsch Jozsa - Balanced Oracle: {deutsch_jozsa('balanced', 3)}")













def 						a_      (__A							,					__A			)							->	list[tuple[int, int, int]]:



					"""simple docstring"""
					__a				:	str			=				sorted(__A							,					key=lambda __A			: edge[2]			)

					__a				:	int			=				list(range(__A			)			)

					def find_parent(__A			):
										if i != parent[i]:
															__a				:	Optional[Any]			=				find_parent(parent[i]			)
										return parent[i]

					__a				:	Any			=				0
					__a				:	Optional[int]			=				[]

					for edge in edges:
										__a				:	Any			=				find_parent(edge[0]			)
										__a				:	Optional[Any]			=				find_parent(edge[1]			)
										if parent_a != parent_b:
															minimum_spanning_tree_cost += edge[2]
															minimum_spanning_tree.append(__A			)
															__a				:	List[str]			=				parent_b

					return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
			UpperCAmelCase__ ,       UpperCAmelCase__			 =	list(map(int, input().strip().split()))
			UpperCAmelCase__			 =	[]

			for _ in range(num_edges):
						UpperCAmelCase__ ,       UpperCAmelCase__ ,       UpperCAmelCase__			 =	(int(x) for x in input().strip().split())
						edges.append((nodea, nodea, cost))

			kruskal(num_nodes, edges)





