




"""simple docstring"""






from __future__ import annotations

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






@dataclass
class lowerCAmelCase__	:






			'''simple docstring'''



			lowerCamelCase__      =			42
			lowerCamelCase__      =			42






class lowerCAmelCase__	:






			'''simple docstring'''



			def __init__(  self  ,      lowercase  ):
							_lowerCamelCase     :			list[list[Edge]]    =    [[] for _ in range(lowercase  )]
							_lowerCamelCase     :			List[Any]    =    size
			def __getitem__(  self  ,      lowercase  ):
							return iter(self._graph[vertex]  )
			@property
			def 					A_    (  self  ):
							return self._size
			def 					A_    (  self  ,      lowercase  ,      lowercase  ,      lowercase  ):
							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(lowercase  ,      lowercase  )  )






			def 					A_    (  self  ,      lowercase  ,      lowercase  ):
							_lowerCamelCase     :			Dict    =    deque([start_vertex]  )
							_lowerCamelCase     :			list[int | None]    =    [None] * self.size
							_lowerCamelCase     :			str    =    0

							while queue:
											_lowerCamelCase     :			Tuple    =    queue.popleft()
											_lowerCamelCase     :			Any    =    distances[current_vertex]
											if current_distance is None:
															continue

											for edge in self[current_vertex]:
															_lowerCamelCase     :			Dict    =    current_distance + edge.weight
															_lowerCamelCase     :			Optional[Any]    =    distances[edge.destination_vertex]
															if (
															    isinstance(lowercase  ,      lowercase  )
															    and new_distance >= dest_vertex_distance
															):
																			continue
															_lowerCamelCase     :			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"""






lowercase__     						=						{
    """meter""": """m""",
    """kilometer""": """km""",
    """megametre""": """Mm""",
    """gigametre""": """Gm""",
    """terametre""": """Tm""",
    """petametre""": """Pm""",
    """exametre""": """Em""",
    """zettametre""": """Zm""",
    """yottametre""": """Ym""",
}
# Exponent of the factor(meter)
lowercase__     						=						{
    """m""": 0,
    """km""": 3,
    """Mm""": 6,
    """Gm""": 9,
    """Tm""": 12,
    """Pm""": 15,
    """Em""": 18,
    """Zm""": 21,
    """Ym""": 24,
}







def      _snake_case			(				lowercase__							,    lowercase__							,    lowercase__		):
				_lowerCamelCase     :			List[Any]    =    from_type.lower().strip('s'		)
				_lowerCamelCase     :			List[Any]    =    to_type.lower().strip('s'		)

				_lowerCamelCase     :			Optional[int]    =    UNIT_SYMBOL.get(lowercase__							,    lowercase__		)
				_lowerCamelCase     :			Any    =    UNIT_SYMBOL.get(lowercase__							,    lowercase__		)

				if from_sanitized not in METRIC_CONVERSION:
								_lowerCamelCase     :			Tuple    =    (
								    f'''Invalid \'from_type\' value: {from_type!r}.\n'''
								    f'''Conversion abbreviations are: {', '.join(lowercase__		)}'''
								)
								raise ValueError(lowercase__		)
				if to_sanitized not in METRIC_CONVERSION:
								_lowerCamelCase     :			Any    =    (
								    f'''Invalid \'to_type\' value: {to_type!r}.\n'''
								    f'''Conversion abbreviations are: {', '.join(lowercase__		)}'''
								)
								raise ValueError(lowercase__		)
				_lowerCamelCase     :			List[Any]    =    METRIC_CONVERSION[from_sanitized]
				_lowerCamelCase     :			int    =    METRIC_CONVERSION[to_sanitized]
				_lowerCamelCase     :			List[str]    =    1

				if from_exponent > to_exponent:
								_lowerCamelCase     :			List[str]    =    from_exponent - to_exponent
				else:
								_lowerCamelCase     :			List[Any]    =    -(to_exponent - from_exponent)

				return value * pow(10							,    lowercase__		)


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

			testmod()