





"""simple docstring"""


from __future__ import annotations




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




      """simple docstring"""

      assert n > 1 and a > 0 and greatest_common_divisor(_lowercase						,_lowercase	) == 1
      (_UpperCamelCase)					:		Union[str, Any]  =				extended_gcd(_lowercase						,_lowercase	)  # Implemented below
      _UpperCamelCase					:		Optional[Any]  =				(b * s) % n
      return x




def     lowercase__			(    lowercase_						,lowercase_	)    ->						List[str]:




      """simple docstring"""

      (_UpperCamelCase)					:		int  =				extended_euclid(_lowercase						,_lowercase	)  # Implemented below
      if b < 0:
            _UpperCamelCase					:		Any  =				(b % n + n) % n
      return b




def     lowercase__			(    lowercase_						,lowercase_						,lowercase_	)    ->						List[Any]:




      """simple docstring"""

      _UpperCamelCase					:		Optional[Any]  =				invert_modulo(_lowercase						,_lowercase	)
      _UpperCamelCase					:		int  =				(b * s) % n
      return x




def     lowercase__			(    lowercase_						,lowercase_	)    ->						Dict:




      """simple docstring"""

      assert a >= 0 and b >= 0

      if b == 0:
            _UpperCamelCase					:		int  =				a, 1, 0
      else:
            (_UpperCamelCase)					:		Any  =				extended_gcd(_lowercase						,a % b	)
            _UpperCamelCase					:		List[Any]  =				q
            _UpperCamelCase					:		Tuple  =				p - q * (a // b)

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

      return (d, x, y)




def     lowercase__			(    lowercase_						,lowercase_	)    ->						List[str]:




      """simple docstring"""

      if b == 0:
            return (1, 0)
      (_UpperCamelCase)					:		int  =				extended_euclid(_lowercase						,a % b	)
      _UpperCamelCase					:		Any  =				a // b
      return (y, x - k * y)




def     lowercase__			(    lowercase_						,lowercase_	)    ->						int:




      """simple docstring"""

      if a < b:
            _UpperCamelCase					:		Tuple  =				b, a

      while a % b != 0:
            _UpperCamelCase					:		Any  =				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 functools import lru_cache





@lru_cache
def        a_				(							_lowercase   ):
						if not isinstance(_lowercase       ,						_lowercase   ):
												raise TypeError('''k must be an integer.'''   )
						if k < 0:
												raise ValueError('''k integer must be greater or equal to zero.'''   )
						if k == 0:
												return 0
						elif k == 1:
												return 1
						else:
												return fibonacci(k - 1   ) + fibonacci(k - 2   )





def        a_				(							_lowercase       ,						_lowercase   ):
						_UpperCamelCase			:					Any     =    len(_lowercase   )
						# Find m such that F_m >= n where F_i is the i_th fibonacci number.
						_UpperCamelCase			:					Optional[int]     =    0
						while True:
												if fibonacci(_lowercase   ) >= len_list:
																		_UpperCamelCase			:					List[Any]     =    i
																		break
												i += 1
						_UpperCamelCase			:					Tuple     =    0
						while fibb_k > 0:
												_UpperCamelCase			:					Union[str, Any]     =    min(
												    offset + fibonacci(fibb_k - 1   )       ,						len_list - 1   )  # Prevent out of range
												_UpperCamelCase			:					Any     =    arr[index_k]
												if item_k_1 == val:
																		return index_k
												elif val < item_k_1:
																		fibb_k -= 1
												elif val > item_k_1:
																		offset += fibonacci(fibb_k - 1   )
																		fibb_k -= 2
						else:
												return -1


if __name__ == "__main__":
						import doctest

						doctest.testmod()



