


from __future__ import annotations

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





@dataclass
class   __a			:
 __lowercase :							int
 __lowercase :							int





class   __a			:
 def __init__(   self				, lowerCAmelCase__ )					->				Any:




        '''simple docstring'''
        lowercase__:   Tuple  			=   [[] for _ in range(lowerCAmelCase__ )]
        lowercase__:   str  			=   size
 def __getitem__(   self				, lowerCAmelCase__ )					->				List[Any]:




        '''simple docstring'''
        return iter(self._graph[vertex] )
 @property
 def 		SCREAMING_SNAKE_CASE__   (   self )					->				Dict:




        '''simple docstring'''
        return self._size
 def 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__				, lowerCAmelCase__				, lowerCAmelCase__ )					->				Optional[Any]:




        '''simple docstring'''


        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 		SCREAMING_SNAKE_CASE__   (   self				, lowerCAmelCase__				, lowerCAmelCase__ )					->				Tuple:




        '''simple docstring'''
        lowercase__:   List[Any]  			=   deque([start_vertex] )
        lowercase__:   int  			=   [None] * self.size
        lowercase__:   Dict  			=   0

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

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




def        a_		(       __lowercase   :	str ) ->  int:
			_snake_case		=			hex_num.strip()
			if not hex_num:
						raise ValueError('No value was passed to the function' )

			_snake_case		=			hex_num[0] == '-'
			if is_negative:
						_snake_case		=			hex_num[1:]

			try:
						_snake_case		=			int(__lowercase       ,					16 )
			except ValueError:
						raise ValueError('Invalid value was passed to the function' )

			_snake_case		=			''
			while int_num > 0:
						_snake_case		=			str(int_num % 2 ) + bin_str
						int_num >>= 1

			return int(('-' + bin_str) if is_negative else bin_str )


if __name__ == "__main__":
			import doctest

			doctest.testmod()