




'''simple docstring'''







from __future__ import annotations



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



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase							):
     (snake_case) :			Any					   = extended_euclid(__lowercase    ,      __lowercase							)  # Implemented below
     if b < 0:
          snake_case :			Optional[Any]					   = (b % n + n) % n
     return b



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase    ,      __lowercase							):
     snake_case :			str					   = invert_modulo(__lowercase    ,      __lowercase							)
     snake_case :			Union[str, Any]					   = (b * s) % n
     return x



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase							):
     assert a >= 0 and b >= 0

     if b == 0:
          snake_case :			List[Any]					   = a, 1, 0
     else:
          (snake_case) :			Dict					   = extended_gcd(__lowercase    ,      a % b							)
          snake_case :			Optional[Any]					   = q
          snake_case :			int					   = 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    ,      __lowercase							):
     if b == 0:
          return (1, 0)
     (snake_case) :			Dict					   = extended_euclid(__lowercase    ,      a % b							)
     snake_case :			Optional[Any]					   = a // b
     return (y, x - k * y)



def 					lowerCamelCase__							(			__lowercase    ,      __lowercase							):
     if a < b:
          snake_case :			List[Any]					   = b, a

     while a % b != 0:
          snake_case :			Dict					   = 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 __future__ import annotations

from collections.abc import Iterable, Iterator
from typing import Any, Generic, TypeVar

lowercase			:      Union[str, Any]			=					TypeVar("""T""", bound=bool)







class 				_a   (Generic[T]  ):





     '''simple docstring'''



     def __init__(							self       ,__a       )			->							None:
          snake_case :			T					   = value
          snake_case :			SkewNode[T] | None					   = None
          snake_case :			SkewNode[T] | None					   = None







     @property
     def  snake_case_			(							self       )			->							T:
          return self._value







     @staticmethod
     def  snake_case_			(							__a       ,__a       )			->							SkewNode[T] | None:
          if not roota:
               return roota

          if not roota:
               return roota

          if roota.value > roota.value:
               snake_case   ,		snake_case :			Tuple					   = roota, roota

          snake_case :			Tuple					   = roota
          snake_case :			Union[str, Any]					   = roota.right
          snake_case :			Any					   = roota.left
          snake_case :			Union[str, Any]					   = SkewNode.merge(__a       ,__a       )

          return result







class 				_a   (Generic[T]  ):





     '''simple docstring'''



     def __init__(							self       ,__a = ()       )			->							None:
          snake_case :			SkewNode[T] | None					   = None
          if data:
               for item in data:
                    self.insert(__a       )







     def __bool__(							self       )			->							bool:
          return self._root is not None







     def __iter__(							self       )			->							Iterator[T]:
          snake_case :			list[Any]					   = []
          while self:
               result.append(self.pop()       )

          # Pushing items back to the heap not to clear it.
          for item in result:
               self.insert(__a       )

          return iter(__a       )







     def  snake_case_			(							self       ,__a       )			->							None:
          snake_case :			List[Any]					   = SkewNode.merge(self._root       ,SkewNode(__a       )       )







     def  snake_case_			(							self       )			->							T | None:
          snake_case :			Tuple					   = self.top()
          snake_case :			int					   = (
              SkewNode.merge(self._root.left       ,self._root.right       ) if self._root else None
          )

          return result







     def  snake_case_			(							self       )			->							T:
          if not self._root:
               raise IndexError("""Can't get top element for the empty heap."""       )
          return self._root.value







     def  snake_case_			(							self       )			->							None:
          snake_case :			Any					   = None


if __name__ == "__main__":
      import doctest

      doctest.testmod()



