


'''simple docstring'''

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

a_						:       List[Any]      			=				TypeVar("""_T""")





class   snake_case					(					Generic[_T]    ):





  """simple docstring"""




  def __init__(					self    ,						UpperCamelCase = None  ):







   """simple docstring"""
   lowerCamelCase_  				=						list(iterable or []  )
   lowerCamelCase_  				=						[]






  def __len__(					self  ):







   """simple docstring"""
   return len(self._stacka  ) + len(self._stacka  )






  def __repr__(					self  ):







   """simple docstring"""
   return f'''Queue({tuple(self._stacka[::-1] + self._stacka  )})'''






  def 						snake_case	(					self    ,						UpperCamelCase  ):







   """simple docstring"""
   self._stacka.append(UpperCamelCase  )







  def 						snake_case	(					self  ):







   """simple docstring"""
   lowerCamelCase_  				=						self._stacka.pop
   lowerCamelCase_  				=						self._stacka.append

   if not self._stacka:
    while self._stacka:
     stacka_append(stacka_pop()  )

   if not self._stacka:
    raise IndexError("Queue is empty"  )
   return self._stacka.pop()


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

     testmod()







'''simple docstring'''

from __future__ import annotations





def __snake_case      (   UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int	):
 if b == 0:
  return (1, 0)
 ((lowerCamelCase_)				,(lowerCamelCase_))  				=						extended_euclid(UpperCAmelCase_      ,       a % b	)
 lowerCamelCase_  				=						a // b
 return (y, x - k * y)





def __snake_case      (   UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int	):
 ((lowerCamelCase_)				,(lowerCamelCase_))  				=						extended_euclid(UpperCAmelCase_      ,       UpperCAmelCase_	)
 lowerCamelCase_  				=						na * na
 lowerCamelCase_  				=						ra * x * na + ra * y * na
 return (n % m + m) % m





def __snake_case      (   UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int	):
 ((lowerCamelCase_)				,(lowerCamelCase_))  				=						extended_euclid(UpperCAmelCase_      ,       UpperCAmelCase_	)
 if b < 0:
  lowerCamelCase_  				=						(b % n + n) % n
 return b





def __snake_case      (   UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int      ,       UpperCAmelCase_		:		int	):
 lowerCamelCase_				,lowerCamelCase_  				=						invert_modulo(UpperCAmelCase_      ,       UpperCAmelCase_	), invert_modulo(UpperCAmelCase_      ,       UpperCAmelCase_	)
 lowerCamelCase_  				=						na * na
 lowerCamelCase_  				=						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)



