





"""simple docstring"""






from __future__ import annotations






def      lowercase__ (					lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int			)    ->			tuple[int, int]:



			'''simple docstring'''
			if b == 0:
						return (1, 0)
			((a__) ,	(a__))  :	List[Any]		 =			extended_euclid(lowerCAmelCase__							,			a % b			)
			a__  :	str		 =			a // b
			return (y, x - k * y)






def      lowercase__ (					lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			((a__) ,	(a__))  :	Tuple		 =			extended_euclid(lowerCAmelCase__							,			lowerCAmelCase__			)
			a__  :	List[str]		 =			na * na
			a__  :	Union[str, Any]		 =			ra * x * na + ra * y * na
			return (n % m + m) % m






def      lowercase__ (					lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			((a__) ,	(a__))  :	Optional[Any]		 =			extended_euclid(lowerCAmelCase__							,			lowerCAmelCase__			)
			if b < 0:
						a__  :	Optional[int]		 =			(b % n + n) % n
			return b






def      lowercase__ (					lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int			)    ->			int:



			'''simple docstring'''
			a__ ,	a__  :	List[Any]		 =			invert_modulo(lowerCAmelCase__							,			lowerCAmelCase__			), invert_modulo(lowerCAmelCase__							,			lowerCAmelCase__			)
			a__  :	Dict		 =			na * na
			a__  :	Any		 =			ra * x * na + ra * y * na
			return (n % m + m) % m


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

		testmod(name='''chinese_remainder_theorem''', verbose=True)
		testmod(name='''chinese_remainder_theorem2''', verbose=True)
		testmod(name='''invert_modulo''', verbose=True)
		testmod(name='''extended_euclid''', verbose=True)






"""simple docstring"""






import functools






def      lowercase__ (					lowerCAmelCase__   :			str							,			lowerCAmelCase__   :			str			)    ->			int:



			'''simple docstring'''
			a__  :	Any		 =			len(lowerCAmelCase__			)
			a__  :	Optional[int]		 =			len(lowerCAmelCase__			)

			@functools.cache
			def min_distance(lowerCAmelCase__   :			int							,			lowerCAmelCase__   :			int			) -> int:
						# if first word index is overflow - delete all from the second word
						if indexa >= len_worda:
									return len_worda - indexa
						# if second word index is overflow - delete all from the first word
						if indexa >= len_worda:
									return len_worda - indexa
						a__  :	List[Any]		 =			int(worda[indexa] != worda[indexa]			)  # current letters not identical
						return min(
						    1 + min_distance(indexa + 1							,			lowerCAmelCase__			)							,			1 + min_distance(lowerCAmelCase__							,			indexa + 1			)							,			diff + min_distance(indexa + 1							,			indexa + 1			)							,			)

			return min_distance(0							,			0			)


if __name__ == "__main__":
		import doctest

		doctest.testmod()