



from __future__ import annotations

from queue import Queue

class 		UpperCAmelCase__      :




			'''simple docstring'''






			def __init__(       self							:			List[str]			):
					'''simple docstring'''





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




			def 			snake_case__					(       self							:			List[Any]			):
					'''simple docstring'''





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




			def 			snake_case__					(       self							:			int	,	a_							:			int	,	a_							:			int			):
					'''simple docstring'''





					if from_vertex in self.vertices:
							self.vertices[from_vertex].append(a_			)
					else:
							__UpperCAmelCase   :					Tuple													=     [to_vertex]




			def 			snake_case__					(       self							:			Optional[Any]	,	a_							:			int			):
					'''simple docstring'''





					__UpperCAmelCase   :					Union[str, Any]													=     set()

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

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

					while not queue.empty():
							__UpperCAmelCase   :					Optional[int]													=     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(a_			)
											visited.add(a_			)
					return visited


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

				testmod(verbose=True)

				__A             =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]










def 	a						(				_UpperCAmelCase							: str						):







		'''simple docstring'''





		__UpperCAmelCase   :					Optional[Any]													=     53_81
		for x in s:
				__UpperCAmelCase   :					str													=     ((hash_value << 5) + hash_value) + ord(_UpperCAmelCase						)
		return hash_value & 0xFFFF_FFFF





