



"""simple docstring"""
from __future__ import annotations



def 				lowerCAmelCase_(      lowercase_   :							Dict  ,      lowercase_   :							Any  ,      lowercase_   :							List[Any]							)		->				int:
				assert n > 1 and a > 0 and greatest_common_divisor(lowercase_  ,      lowercase_							) == 1
				((_lowerCamelCase)     ,   (_lowerCamelCase)     ,   (_lowerCamelCase))					     = extended_gcd(lowercase_  ,      lowercase_							)  # Implemented below
				_lowerCamelCase					     = (b * s) % n
				return x



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



def 				lowerCAmelCase_(      lowercase_   :							List[Any]  ,      lowercase_   :							Union[str, Any]  ,      lowercase_   :							Optional[Any]							)		->				int:
				_lowerCamelCase					     = invert_modulo(lowercase_  ,      lowercase_							)
				_lowerCamelCase					     = (b * s) % n
				return x



def 				lowerCAmelCase_(      lowercase_   :							Any  ,      lowercase_   :							List[Any]							)		->				tuple[int, int, int]:
				assert a >= 0 and b >= 0

				if b == 0:
								_lowerCamelCase     ,   _lowerCamelCase     ,   _lowerCamelCase					     = a, 1, 0
				else:
								((_lowerCamelCase)     ,   (_lowerCamelCase)     ,   (_lowerCamelCase))					     = extended_gcd(lowercase_  ,      a % b							)
								_lowerCamelCase					     = q
								_lowerCamelCase					     = p - q * (a // b)

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

				return (d, x, y)



def 				lowerCAmelCase_(      lowercase_   :							List[str]  ,      lowercase_   :							List[str]							)		->				tuple[int, int]:
				if b == 0:
								return (1, 0)
				((_lowerCamelCase)     ,   (_lowerCamelCase))					     = extended_euclid(lowercase_  ,      a % b							)
				_lowerCamelCase					     = a // b
				return (y, x - k * y)



def 				lowerCAmelCase_(      lowercase_   :							Optional[Any]  ,      lowercase_   :							Dict							)		->				int:
				if a < b:
								_lowerCamelCase     ,   _lowerCamelCase					     = b, a

				while a % b != 0:
								_lowerCamelCase     ,   _lowerCamelCase					     = 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)







'''simple docstring'''







from collections import namedtuple

_a					: Any      =    namedtuple("""from_to""", """from_ to""")

_a					: Dict      =    {
    """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""",
}

_a					: Optional[Any]      =    {
    """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.28084),
    """yd""": from_to(0.9144, 1.09361),
    """mi""": from_to(1609.34, 0.000621371),
}





def    _lowerCAmelCase						(						lowercase					,	lowercase					,	lowercase	)					->					float:
			__lowerCAmelCase											=				from_type.lower().rstrip("""s"""	)
			__lowerCAmelCase											=				TYPE_CONVERSION.get(lowercase					,	lowercase	)
			__lowerCAmelCase											=				to_type.lower().rstrip("""s"""	)
			__lowerCAmelCase											=				TYPE_CONVERSION.get(lowercase					,	lowercase	)
			if new_from not in METRIC_CONVERSION:
						__lowerCAmelCase											=				(
						    f'Invalid \'from_type\' value: {from_type!r}.\n'
						    f'Conversion abbreviations are: {", ".join(lowercase	)}'
						)
						raise ValueError(lowercase	)
			if new_to not in METRIC_CONVERSION:
						__lowerCAmelCase											=				(
						    f'Invalid \'to_type\' value: {to_type!r}.\n'
						    f'Conversion abbreviations are: {", ".join(lowercase	)}'
						)
						raise ValueError(lowercase	)
			return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to


if __name__ == "__main__":
	import doctest

	doctest.testmod()

