






"""simple docstring"""



# Author: OMKAR PATHAK, Nwachukwu Chidiebere

# Use a Python dictionary to construct the graph.
from __future__ import annotations

from pprint import pformat
from typing import Generic, TypeVar

_UpperCamelCase		:  Optional[Any]						=		TypeVar('T')

class        a     (   Generic[T]	):







    def __init__(			self							,		_lowerCamelCase = True       ):
      lowercase							    =       {}  # dictionary of lists
      lowercase							    =       directed







    def 			UpperCamelCase_      (			self							,		_lowerCamelCase							,		_lowerCamelCase       ):

      if not self.directed:  # For undirected graphs
        # if both source vertex and destination vertex are both present in the
        # adjacency list, add destination vertex to source vertex list of adjacent
        # vertices and add source vertex to destination vertex list of adjacent
        # vertices.
        if source_vertex in self.adj_list and destination_vertex in self.adj_list:
          self.adj_list[source_vertex].append(_lowerCamelCase       )
          self.adj_list[destination_vertex].append(_lowerCamelCase       )
        # if only source vertex is present in adjacency list, add destination vertex
        # to source vertex list of adjacent vertices, then create a new vertex with
        # destination vertex as key and assign a list containing the source vertex
        # as it's first adjacent vertex.
        elif source_vertex in self.adj_list:
          self.adj_list[source_vertex].append(_lowerCamelCase       )
          lowercase							    =       [source_vertex]
        # if only destination vertex is present in adjacency list, add source vertex
        # to destination vertex list of adjacent vertices, then create a new vertex
        # with source vertex as key and assign a list containing the source vertex
        # as it's first adjacent vertex.
        elif destination_vertex in self.adj_list:
          self.adj_list[destination_vertex].append(_lowerCamelCase       )
          lowercase							    =       [destination_vertex]
        # if both source vertex and destination vertex are not present in adjacency
        # list, create a new vertex with source vertex as key and assign a list
        # containing the destination vertex as it's first adjacent vertex also
        # create a new vertex with destination vertex as key and assign a list
        # containing the source vertex as it's first adjacent vertex.
        else:
          lowercase							    =       [destination_vertex]
          lowercase							    =       [source_vertex]
      else:  # For directed graphs
        # if both source vertex and destination vertex are present in adjacency
        # list, add destination vertex to source vertex list of adjacent vertices.
        if source_vertex in self.adj_list and destination_vertex in self.adj_list:
          self.adj_list[source_vertex].append(_lowerCamelCase       )
        # if only source vertex is present in adjacency list, add destination
        # vertex to source vertex list of adjacent vertices and create a new vertex
        # with destination vertex as key, which has no adjacent vertex
        elif source_vertex in self.adj_list:
          self.adj_list[source_vertex].append(_lowerCamelCase       )
          lowercase							    =       []
        # if only destination vertex is present in adjacency list, create a new
        # vertex with source vertex as key and assign a list containing destination
        # vertex as first adjacent vertex
        elif destination_vertex in self.adj_list:
          lowercase							    =       [destination_vertex]
        # if both source vertex and destination vertex are not present in adjacency
        # list, create a new vertex with source vertex as key and a list containing
        # destination vertex as it's first adjacent vertex. Then create a new vertex
        # with destination vertex as key, which has no adjacent vertex
        else:
          lowercase							    =       [destination_vertex]
          lowercase							    =       []

      return self







    def __repr__(			self       ):
      return pformat(self.adj_list       )










"""simple docstring"""



_UpperCamelCase		:  List[str]						=		{
    'meter': 'm',
    'kilometer': 'km',
    'megametre': 'Mm',
    'gigametre': 'Gm',
    'terametre': 'Tm',
    'petametre': 'Pm',
    'exametre': 'Em',
    'zettametre': 'Zm',
    'yottametre': 'Ym',
}
# Exponent of the factor(meter)
_UpperCamelCase		:  str						=		{
    'm': 0,
    'km': 3,
    'Mm': 6,
    'Gm': 9,
    'Tm': 1_2,
    'Pm': 1_5,
    'Em': 1_8,
    'Zm': 2_1,
    'Ym': 2_4,
}
def 						_SCREAMING_SNAKE_CASE (    __snake_case			:  float		,					__snake_case			:  str		,					__snake_case			:  str    ):





  '''simple docstring'''





  lowercase							    =       from_type.lower().strip('s'    )
  lowercase							    =       to_type.lower().strip('s'    )

  lowercase							    =       UNIT_SYMBOL.get(__snake_case		,					__snake_case    )
  lowercase							    =       UNIT_SYMBOL.get(__snake_case		,					__snake_case    )

  if from_sanitized not in METRIC_CONVERSION:
    lowercase							    =       (
        f'Invalid \'from_type\' value: {from_type!r}.\n'
        f'Conversion abbreviations are: {", ".join(__snake_case    )}'
    )
    raise ValueError(__snake_case    )
  if to_sanitized not in METRIC_CONVERSION:
    lowercase							    =       (
        f'Invalid \'to_type\' value: {to_type!r}.\n'
        f'Conversion abbreviations are: {", ".join(__snake_case    )}'
    )
    raise ValueError(__snake_case    )
  lowercase							    =       METRIC_CONVERSION[from_sanitized]
  lowercase							    =       METRIC_CONVERSION[to_sanitized]
  lowercase							    =       1

  if from_exponent > to_exponent:
    lowercase							    =       from_exponent - to_exponent
  else:
    lowercase							    =       -(to_exponent - from_exponent)

  return value * pow(10		,					__snake_case    )


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

    testmod()


