





"""simple docstring"""




from __future__ import annotations

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


@dataclass
class  __UpperCamelCase       :
							lowerCamelCase     :      Optional[int]         =42
							lowerCamelCase     :      Union[str, Any]         =42


class  __UpperCamelCase       :






							def __init__(     self   ,      lowerCAmelCase__   )			->				Tuple:
								a   :	list[list[Edge]]			=       [[] for _ in range(__lowerCamelCase   )]
								a   :	int			=       size






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






							@property
							def 					__a     (     self   )			->				Tuple:
								return self._size






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				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(__lowerCamelCase   ,      __lowerCamelCase   )   )






							def 					__a     (     self   ,      lowerCAmelCase__   ,      lowerCAmelCase__   )			->				int | None:
								a   :	List[Any]			=       deque([start_vertex]   )
								a   :	list[int | None]			=       [None] * self.size
								a   :	str			=       0

								while queue:
									a   :	Union[str, Any]			=       queue.popleft()
									a   :	int			=       distances[current_vertex]
									if current_distance is None:
										continue

									for edge in self[current_vertex]:
										a   :	Tuple			=       current_distance + edge.weight
										a   :	str			=       distances[edge.destination_vertex]
										if (
										    isinstance(__lowerCamelCase   ,      __lowerCamelCase   )
										    and new_distance >= dest_vertex_distance
										):
											continue
										a   :	Tuple			=       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 baseaa






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					str      )				->bytes:






	'''simple docstring'''






	return baseaa.aaaencode(string.encode("utf-8"      )      )






def    _SCREAMING_SNAKE_CASE	(			_lowercase		:					bytes      )				->str:






	'''simple docstring'''






	return baseaa.aaadecode(_lowercase      ).decode("utf-8"      )


if __name__ == "__main__":
		import doctest

		doctest.testmod()


