


from __future__ import annotations
def 	_lowerCamelCase  (		A_  :	Any							,  A_  :	Optional[Any]							,  A_  :	Union[str, Any]      )			->			int:

   '''simple docstring'''






   assert n > 1 and a > 0 and greatest_common_divisor(lowerCamelCase__							,  lowerCamelCase__      ) == 1
   (UpperCamelCase__) :			Tuple 						=extended_gcd(lowerCamelCase__							,  lowerCamelCase__      )  # Implemented below
   UpperCamelCase__ :			str 						=(b * s) % n
   return x
def 	_lowerCamelCase  (		A_  :	Tuple							,  A_  :	Optional[Any]      )			->			int:

   '''simple docstring'''






   (UpperCamelCase__) :			Optional[int] 						=extended_euclid(lowerCamelCase__							,  lowerCamelCase__      )  # Implemented below
   if b < 0:
      UpperCamelCase__ :			Any 						=(b % n + n) % n
   return b
def 	_lowerCamelCase  (		A_  :	Optional[Any]							,  A_  :	Dict							,  A_  :	List[Any]      )			->			int:

   '''simple docstring'''






   UpperCamelCase__ :			Any 						=invert_modulo(lowerCamelCase__							,  lowerCamelCase__      )
   UpperCamelCase__ :			List[Any] 						=(b * s) % n
   return x
def 	_lowerCamelCase  (		A_  :	int							,  A_  :	Union[str, Any]      )			->			tuple[int, int, int]:

   '''simple docstring'''






   assert a >= 0 and b >= 0

   if b == 0:
      UpperCamelCase__ :			str 						=a, 1, 0
   else:
      (UpperCamelCase__) :			Tuple 						=extended_gcd(lowerCamelCase__							,  a % b      )
      UpperCamelCase__ :			Union[str, Any] 						=q
      UpperCamelCase__ :			Any 						=p - q * (a // b)

   assert a % d == 0 and b % d == 0
   assert d == a * x + b * y

   return (d, x, y)
def 	_lowerCamelCase  (		A_  :	int							,  A_  :	List[Any]      )			->			tuple[int, int]:

   '''simple docstring'''






   if b == 0:
      return (1, 0)
   (UpperCamelCase__) :			List[str] 						=extended_euclid(lowerCamelCase__							,  a % b      )
   UpperCamelCase__ :			Optional[Any] 						=a // b
   return (y, x - k * y)
def 	_lowerCamelCase  (		A_  :	Any							,  A_  :	List[Any]      )			->			int:

   '''simple docstring'''






   if a < b:
      UpperCamelCase__ :			str 						=b, a

   while a % b != 0:
      UpperCamelCase__ :			str 						=b, a % b

   return b


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

     testmod(name="""modular_division""", verbose=True)
     testmod(name="""modular_division2""", verbose=True)
     testmod(name="""invert_modulo""", verbose=True)
     testmod(name="""extended_gcd""", verbose=True)
     testmod(name="""extended_euclid""", verbose=True)
     testmod(name="""greatest_common_divisor""", verbose=True)









from collections import namedtuple

UpperCamelCase											=      namedtuple('''from_to''', '''from_ to''')

UpperCamelCase											=      {
    '''millimeter''': '''mm''',
    '''centimeter''': '''cm''',
    '''meter''': '''m''',
    '''kilometer''': '''km''',
    '''inch''': '''in''',
    '''inche''': '''in''',  # Trailing 's' has been stripped off
    '''feet''': '''ft''',
    '''foot''': '''ft''',
    '''yard''': '''yd''',
    '''mile''': '''mi''',
}

UpperCamelCase											=      {
    '''mm''': from_to(0.001, 1_0_0_0),
    '''cm''': from_to(0.01, 1_0_0),
    '''m''': from_to(1, 1),
    '''km''': from_to(1_0_0_0, 0.001),
    '''in''': from_to(0.0254, 39.3701),
    '''ft''': from_to(0.3048, 3.2_8084),
    '''yd''': from_to(0.9144, 1.0_9361),
    '''mi''': from_to(1609.34, 0.0_0062_1371),
}




def       _a   (							lowerCamelCase__ ,			lowerCamelCase__ ,			lowerCamelCase__				)  ->      float:
 lowerCamelCase_							:    List[Any]							=     from_type.lower().rstrip('s'				)
 lowerCamelCase_							:    Optional[Any]							=     TYPE_CONVERSION.get(lowerCamelCase__ ,			lowerCamelCase__				)
 lowerCamelCase_							:    List[Any]							=     to_type.lower().rstrip('s'				)
 lowerCamelCase_							:    Optional[int]							=     TYPE_CONVERSION.get(lowerCamelCase__ ,			lowerCamelCase__				)
 if new_from not in METRIC_CONVERSION:
  lowerCamelCase_							:    List[Any]							=     (
      F'Invalid \'from_type\' value: {from_type!r}.\n'
      F'Conversion abbreviations are: {", ".join(lowerCamelCase__				)}'
  )
  raise ValueError(lowerCamelCase__				)
 if new_to not in METRIC_CONVERSION:
  lowerCamelCase_							:    List[str]							=     (
      F'Invalid \'to_type\' value: {to_type!r}.\n'
      F'Conversion abbreviations are: {", ".join(lowerCamelCase__				)}'
  )
  raise ValueError(lowerCamelCase__				)
 return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to


if __name__ == "__main__":
       import doctest

       doctest.testmod()
