
'''simple docstring'''







from __future__ import annotations
def       snake_case_	(       __SCREAMING_SNAKE_CASE      :				int							):



						"""simple docstring"""





						for r in range(1   ,   __SCREAMING_SNAKE_CASE							):
												lowercase_			:  Union[str, Any]									= []
												for x in range(n - 1							):
																		lowercase_			:  Optional[Any]									= pow(__SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE   ,   __SCREAMING_SNAKE_CASE							)
																		if val in li:
																								break
																		li.append(__SCREAMING_SNAKE_CASE							)
												else:
																		return r
						return None


if __name__ == "__main__":
							_lowercase				:						Any												= int(input("Enter a prime number q: "))
							_lowercase				:						Optional[Any]												= find_primitive(q)
							if a is None:
														print(f"""Cannot find the primitive for the value: {a!r}""")
							else:
														_lowercase				:						int												= int(input("Enter private key of A: "))
														_lowercase				:						str												= pow(a, a_private, q)
														_lowercase				:						str												= int(input("Enter private key of B: "))
														_lowercase				:						List[Any]												= pow(a, b_private, q)

														_lowercase				:						Any												= pow(b_public, a_private, q)
														_lowercase				:						List[Any]												= pow(a_public, b_private, q)

														print("The key value generated by A is: ", a_secret)
														print("The key value generated by B is: ", b_secret)





'''simple docstring'''







from __future__ import annotations

from queue import Queue






class 				lowerCAmelCase__     :






					def __init__(     self	):


											"""simple docstring"""





											lowercase_			:  dict[int, list[int]]									= {}






					def 			_snake_case					(     self	):


											"""simple docstring"""





											for i in self.vertices:
																	print(__SCREAMING_SNAKE_CASE       ,							''' : '''       ,							''' -> '''.join([str(__SCREAMING_SNAKE_CASE	) for j in self.vertices[i]]	)	)






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											if from_vertex in self.vertices:
																	self.vertices[from_vertex].append(__SCREAMING_SNAKE_CASE	)
											else:
																	lowercase_			:  Optional[Any]									= [to_vertex]






					def 			_snake_case					(     self       ,							__SCREAMING_SNAKE_CASE	):


											"""simple docstring"""





											lowercase_			:  List[Any]									= set()

											# create a first in first out queue to store all the vertices for BFS
											lowercase_			:  Queue									= Queue()

											# mark the source node as visited and enqueue it
											visited.add(__SCREAMING_SNAKE_CASE	)
											queue.put(__SCREAMING_SNAKE_CASE	)

											while not queue.empty():
																	lowercase_			:  List[Any]									= queue.get()

																	# loop through all adjacent vertex and enqueue it if not yet visited
																	for adjacent_vertex in self.vertices[vertex]:
																							if adjacent_vertex not in visited:
																													queue.put(__SCREAMING_SNAKE_CASE	)
																													visited.add(__SCREAMING_SNAKE_CASE	)
											return visited


if __name__ == "__main__":
							from doctest import testmod

							testmod(verbose=True)

							_lowercase				:						Optional[int]												= Graph()
							g.add_edge(0, 1)
							g.add_edge(0, 2)
							g.add_edge(1, 2)
							g.add_edge(2, 0)
							g.add_edge(2, 3)
							g.add_edge(3, 3)

							g.print_graph()
							# 0  :  1 -> 2
							# 1  :  2
							# 2  :  0 -> 3
							# 3  :  3

							assert sorted(g.bfs(2)) == [0, 1, 2, 3]



