

"""simple docstring"""




from collections import deque
from math import floor
from random import random
from time import time
class 			_UpperCAmelCase					:



	def __init__(   self			:    Optional[Any]		):
		__UpperCAmelCase							=      {}



	def     a   (   self			:    List[str]       ,  _lowercase			:    List[Any]       ,  _lowercase			:    Dict       ,  _lowercase			:    Optional[int]=1		):



		if self.graph.get(UpperCamelCase__		):
			if self.graph[u].count([w, v]		) == 0:
				self.graph[u].append([w, v]		)
		else:
			__UpperCAmelCase							=      [[w, v]]
		if not self.graph.get(UpperCamelCase__		):
			__UpperCAmelCase							=      []



	def     a   (   self			:    Optional[int]		):
		return list(self.graph		)



	def     a   (   self			:    Dict       ,  _lowercase			:    List[str]       ,  _lowercase			:    str		):



		if self.graph.get(UpperCamelCase__		):
			for _ in self.graph[u]:
				if _[1] == v:
					self.graph[u].remove(UpperCamelCase__		)



	def     a   (   self			:    Optional[int]       ,  _lowercase			:    List[str]=-2       ,  _lowercase			:    Any=-1		):



		if s == d:
			return []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		if s == -2:
			__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      s

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if visited.count(node[1]		) < 1:
						if node[1] == d:
							visited.append(UpperCamelCase__		)
							return visited
						else:
							stack.append(node[1]		)
							visited.append(node[1]		)
							__UpperCAmelCase							=      node[1]
							break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return visited



	def     a   (   self			:    str       ,  _lowercase			:    str=-1		):



		if c == -1:
			__UpperCAmelCase							=      floor(random() * 1_00_00		) + 10
		for i in range(UpperCamelCase__		):
			# every vertex has max 100 edges
			for _ in range(floor(random() * 1_02		) + 1		):
				__UpperCAmelCase							=      floor(random() * c		) + 1
				if n != i:
					self.add_pair(UpperCamelCase__       ,  UpperCamelCase__       ,  1		)



	def     a   (   self			:    Union[str, Any]       ,  _lowercase			:    int=-2		):
		__UpperCAmelCase							=      deque()
		__UpperCAmelCase							=      []
		if s == -2:
			__UpperCAmelCase							=      list(self.graph		)[0]
		d.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		while d:
			__UpperCAmelCase							=      d.popleft()
			if len(self.graph[s]		) != 0:
				for node in self.graph[s]:
					if visited.count(node[1]		) < 1:
						d.append(node[1]		)
						visited.append(node[1]		)
		return visited



	def     a   (   self			:    List[str]       ,  _lowercase			:    Tuple		):
		__UpperCAmelCase							=      0
		for x in self.graph:
			for y in self.graph[x]:
				if y[1] == u:
					count += 1
		return count



	def     a   (   self			:    List[str]       ,  _lowercase			:    Dict		):
		return len(self.graph[u]		)



	def     a   (   self			:    Union[str, Any]       ,  _lowercase			:    Optional[Any]=-2		):
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		if s == -2:
			__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      s
		__UpperCAmelCase							=      []

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if visited.count(node[1]		) < 1:
						stack.append(node[1]		)
						visited.append(node[1]		)
						__UpperCAmelCase							=      node[1]
						break

            # check if all the children are visited
			if s == ss:
				sorted_nodes.append(stack.pop()		)
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return sorted_nodes



	def     a   (   self			:    Optional[Any]		):
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      -2
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      s
		__UpperCAmelCase							=      False
		__UpperCAmelCase							=      set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]		) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]		) > 0
					    and not on_the_way_back
					):
						__UpperCAmelCase							=      len(UpperCamelCase__		) - 1
						while len_stack >= 0:
							if stack[len_stack] == node[1]:
								anticipating_nodes.add(node[1]		)
								break
							else:
								anticipating_nodes.add(stack[len_stack]		)
								len_stack -= 1
					if visited.count(node[1]		) < 1:
						stack.append(node[1]		)
						visited.append(node[1]		)
						__UpperCAmelCase							=      node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				__UpperCAmelCase							=      True
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      False
				indirect_parents.append(UpperCamelCase__		)
				__UpperCAmelCase							=      s
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return list(UpperCamelCase__		)



	def     a   (   self			:    List[Any]		):
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      -2
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      s
		__UpperCAmelCase							=      False
		__UpperCAmelCase							=      set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]		) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]		) > 0
					    and not on_the_way_back
					):
						__UpperCAmelCase							=      len(UpperCamelCase__		) - 1
						while len_stack_minus_one >= 0:
							if stack[len_stack_minus_one] == node[1]:
								anticipating_nodes.add(node[1]		)
								break
							else:
								return True
					if visited.count(node[1]		) < 1:
						stack.append(node[1]		)
						visited.append(node[1]		)
						__UpperCAmelCase							=      node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				__UpperCAmelCase							=      True
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      False
				indirect_parents.append(UpperCamelCase__		)
				__UpperCAmelCase							=      s
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return False



	def     a   (   self			:    List[str]       ,  _lowercase			:    int=-2       ,  _lowercase			:    str=-1		):
		__UpperCAmelCase							=      time()
		self.dfs(UpperCamelCase__       ,  UpperCamelCase__		)
		__UpperCAmelCase							=      time()
		return end - begin



	def     a   (   self			:    Optional[int]       ,  _lowercase			:    List[Any]=-2		):
		__UpperCAmelCase							=      time()
		self.bfs(UpperCamelCase__		)
		__UpperCAmelCase							=      time()
		return end - begin






class 			_UpperCAmelCase					:



	def __init__(   self			:    Dict		):
		__UpperCAmelCase							=      {}



	def     a   (   self			:    Union[str, Any]       ,  _lowercase			:    Optional[int]       ,  _lowercase			:    int       ,  _lowercase			:    List[Any]=1		):



		if self.graph.get(UpperCamelCase__		):
			# if there already is a edge
			if self.graph[u].count([w, v]		) == 0:
				self.graph[u].append([w, v]		)
		else:
			# if u does not exist
			__UpperCAmelCase							=      [[w, v]]
		# add the other way
		if self.graph.get(UpperCamelCase__		):
			# if there already is a edge
			if self.graph[v].count([w, u]		) == 0:
				self.graph[v].append([w, u]		)
		else:
			# if u does not exist
			__UpperCAmelCase							=      [[w, u]]



	def     a   (   self			:    Optional[int]       ,  _lowercase			:    Optional[Any]       ,  _lowercase			:    Tuple		):



		if self.graph.get(UpperCamelCase__		):
			for _ in self.graph[u]:
				if _[1] == v:
					self.graph[u].remove(UpperCamelCase__		)
        # the other way round
		if self.graph.get(UpperCamelCase__		):
			for _ in self.graph[v]:
				if _[1] == u:
					self.graph[v].remove(UpperCamelCase__		)



	def     a   (   self			:    Tuple       ,  _lowercase			:    int=-2       ,  _lowercase			:    List[Any]=-1		):



		if s == d:
			return []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		if s == -2:
			__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      s

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if visited.count(node[1]		) < 1:
						if node[1] == d:
							visited.append(UpperCamelCase__		)
							return visited
						else:
							stack.append(node[1]		)
							visited.append(node[1]		)
							__UpperCAmelCase							=      node[1]
							break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return visited



	def     a   (   self			:    List[Any]       ,  _lowercase			:    List[str]=-1		):



		if c == -1:
			__UpperCAmelCase							=      floor(random() * 1_00_00		) + 10
		for i in range(UpperCamelCase__		):
			# every vertex has max 100 edges
			for _ in range(floor(random() * 1_02		) + 1		):
				__UpperCAmelCase							=      floor(random() * c		) + 1
				if n != i:
					self.add_pair(UpperCamelCase__       ,  UpperCamelCase__       ,  1		)



	def     a   (   self			:    Union[str, Any]       ,  _lowercase			:    Optional[Any]=-2		):
		__UpperCAmelCase							=      deque()
		__UpperCAmelCase							=      []
		if s == -2:
			__UpperCAmelCase							=      list(self.graph		)[0]
		d.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		while d:
			__UpperCAmelCase							=      d.popleft()
			if len(self.graph[s]		) != 0:
				for node in self.graph[s]:
					if visited.count(node[1]		) < 1:
						d.append(node[1]		)
						visited.append(node[1]		)
		return visited



	def     a   (   self			:    Dict       ,  _lowercase			:    Optional[Any]		):
		return len(self.graph[u]		)



	def     a   (   self			:    Union[str, Any]		):
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      -2
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      s
		__UpperCAmelCase							=      False
		__UpperCAmelCase							=      set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]		) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]		) > 0
					    and not on_the_way_back
					):
						__UpperCAmelCase							=      len(UpperCamelCase__		) - 1
						while len_stack >= 0:
							if stack[len_stack] == node[1]:
								anticipating_nodes.add(node[1]		)
								break
							else:
								anticipating_nodes.add(stack[len_stack]		)
								len_stack -= 1
					if visited.count(node[1]		) < 1:
						stack.append(node[1]		)
						visited.append(node[1]		)
						__UpperCAmelCase							=      node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				__UpperCAmelCase							=      True
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      False
				indirect_parents.append(UpperCamelCase__		)
				__UpperCAmelCase							=      s
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return list(UpperCamelCase__		)



	def     a   (   self			:    List[Any]		):
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      list(self.graph		)[0]
		stack.append(UpperCamelCase__		)
		visited.append(UpperCamelCase__		)
		__UpperCAmelCase							=      -2
		__UpperCAmelCase							=      []
		__UpperCAmelCase							=      s
		__UpperCAmelCase							=      False
		__UpperCAmelCase							=      set()

		while True:
			# check if there is any non isolated nodes
			if len(self.graph[s]		) != 0:
				__UpperCAmelCase							=      s
				for node in self.graph[s]:
					if (
					    visited.count(node[1]		) > 0
					    and node[1] != parent
					    and indirect_parents.count(node[1]		) > 0
					    and not on_the_way_back
					):
						__UpperCAmelCase							=      len(UpperCamelCase__		) - 1
						while len_stack_minus_one >= 0:
							if stack[len_stack_minus_one] == node[1]:
								anticipating_nodes.add(node[1]		)
								break
							else:
								return True
					if visited.count(node[1]		) < 1:
						stack.append(node[1]		)
						visited.append(node[1]		)
						__UpperCAmelCase							=      node[1]
						break

            # check if all the children are visited
			if s == ss:
				stack.pop()
				__UpperCAmelCase							=      True
				if len(UpperCamelCase__		) != 0:
					__UpperCAmelCase							=      stack[len(UpperCamelCase__		) - 1]
			else:
				__UpperCAmelCase							=      False
				indirect_parents.append(UpperCamelCase__		)
				__UpperCAmelCase							=      s
				__UpperCAmelCase							=      ss

			# check if se have reached the starting point
			if len(UpperCamelCase__		) == 0:
				return False



	def     a   (   self			:    str		):
		return list(self.graph		)



	def     a   (   self			:    str       ,  _lowercase			:    Optional[Any]=-2       ,  _lowercase			:    Any=-1		):
		__UpperCAmelCase							=      time()
		self.dfs(UpperCamelCase__       ,  UpperCamelCase__		)
		__UpperCAmelCase							=      time()
		return end - begin



	def     a   (   self			:    Any       ,  _lowercase			:    List[Any]=-2		):
		__UpperCAmelCase							=      time()
		self.bfs(UpperCamelCase__		)
		__UpperCAmelCase							=      time()
		return end - begin






import math

import numpy as np
import qiskit
from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute





def __UpperCamelCase			(       _A = 3  ):
						if isinstance(_A ,  _A  ):
												raise TypeError('''number of qubits must be a integer.'''  )
						if number_of_qubits <= 0:
												raise ValueError('''number of qubits must be > 0.'''  )
						if math.floor(_A  ) != number_of_qubits:
												raise ValueError('''number of qubits must be exact integer.'''  )
						if number_of_qubits > 10:
												raise ValueError('''number of qubits too large to simulate(>10).'''  )

						lowerCAmelCase_      			=  QuantumRegister(_A ,  '''qr'''  )
						lowerCAmelCase_      			=  ClassicalRegister(_A ,  '''cr'''  )

						lowerCAmelCase_      			=  QuantumCircuit(_A ,  _A  )

						lowerCAmelCase_      			=  number_of_qubits

						for i in range(_A  ):
												quantum_circuit.h(number_of_qubits - i - 1  )
												counter -= 1
												for j in range(_A  ):
																		quantum_circuit.cp(np.pi / 2 ** (counter - j) ,  _A ,  _A  )

						for k in range(number_of_qubits // 2  ):
												quantum_circuit.swap(_A ,  number_of_qubits - k - 1  )

						# measure all the qubits
						quantum_circuit.measure(_A ,  _A  )
						# simulate with 10000 shots
						lowerCAmelCase_      			=  Aer.get_backend('''qasm_simulator'''  )
						lowerCAmelCase_      			=  execute(_A ,  _A ,  shots=10000  )

						return job.result().get_counts(_A  )


if __name__ == "__main__":
						print(
						    f"Total count for quantum fourier transform state is: \
    {quantum_fourier_transform(3)}"
						)




