



'''simple docstring'''




from __future__ import annotations

from collections import deque
from collections.abc import Iterator
from dataclasses import dataclass

@dataclass
class     UpperCamelCase_				:
	lowercase    =				42
	lowercase    =				42




class     UpperCamelCase_				:





	def __init__(						self	,	A					)    ->    Any:
								UpperCAmelCase  :	list[list[Edge]]							  =	[[] for _ in range(A					)]
								UpperCAmelCase  :	Dict							  =	size





	def __getitem__(						self	,	A					)    ->    Iterator[Edge]:
								return iter(self._graph[vertex]					)





	@property
	def 				_lowercase(						self					)    ->    Optional[int]:
								return self._size





	def 				_lowercase(						self	,	A	,	A	,	A					)    ->    List[str]:
								if weight not in (0, 1):
															raise ValueError("""Edge weight must be either 0 or 1."""					)

								if to_vertex < 0 or to_vertex >= self.size:
															raise ValueError("""Vertex indexes must be in [0; size)."""					)

								self._graph[from_vertex].append(Edge(A	,	A					)					)






	def 				_lowercase(						self	,	A	,	A					)    ->    int | None:
								UpperCAmelCase  :	List[str]							  =	deque([start_vertex]					)
								UpperCAmelCase  :	list[int | None]							  =	[None] * self.size
								UpperCAmelCase  :	Optional[int]							  =	0

								while queue:
															UpperCAmelCase  :	Optional[Any]							  =	queue.popleft()
															UpperCAmelCase  :	int							  =	distances[current_vertex]
															if current_distance is None:
																						continue

															for edge in self[current_vertex]:
																						UpperCAmelCase  :	List[Any]							  =	current_distance + edge.weight
																						UpperCAmelCase  :	Dict							  =	distances[edge.destination_vertex]
																						if (
																						    isinstance(A	,	A					)
																						    and new_distance >= dest_vertex_distance
																						):
																													continue
																						UpperCAmelCase  :	Union[str, Any]							  =	new_distance
																						if edge.weight == 0:
																													queue.appendleft(edge.destination_vertex					)
																						else:
																													queue.append(edge.destination_vertex					)

								if distances[finish_vertex] is None:
															raise ValueError("""No path from start_vertex to finish_vertex."""					)

								return distances[finish_vertex]


if __name__ == "__main__":
							import doctest

							doctest.testmod()






'''simple docstring'''




import math



def    __lowerCamelCase						(      _lowercase	)   ->    bool:
							assert isinstance(_lowercase			,       _lowercase	) and (
							    number >= 0
							), "'number' must been an int and positive"

							if 1 < number < 4:
														# 2 and 3 are primes
														return True
							elif number < 2 or not number % 2:
														# Negatives, 0, 1 and all even numbers are not primes
														return False

							UpperCAmelCase  :	str							  =	range(3			,       int(math.sqrt(_lowercase	) + 1	)			,       2	)
							return not any(not number % i for i in odd_numbers	)



def    __lowerCamelCase						(      _lowercase			,       _lowercase=1			,       **_lowercase	)   ->    Union[str, Any]:
							UpperCAmelCase  :	Optional[int]							  =	factor * value
							UpperCAmelCase  :	List[Any]							  =	value

							while not is_prime(_lowercase	):
														value += 1 if not ("desc" in kwargs and kwargs["desc"] is True) else -1

							if value == first_value_val:
														return next_prime(value + 1			,       **_lowercase	)
							return value

