





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

__lowerCamelCase			:	Dict					    =	TypeVar("""_T""")



class    A__  (			Generic[_T]     ):





      def __init__(					self			,				A_ = None  ):
       '''simple docstring'''




       UpperCamelCase      :   list[_T]			      =  list(iterable or []  )
       UpperCamelCase      :   list[_T]			      =  []





      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 			__UpperCamelCase(					self			,				A_  ):
       '''simple docstring'''




       self._stacka.append(A_  )





      def 			__UpperCamelCase(					self  ):
       '''simple docstring'''




       UpperCamelCase      :   Any			      =  self._stacka.pop
       UpperCamelCase      :   Any			      =  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()







def 						A_							(	_lowerCAmelCase				,  _lowerCAmelCase	)		->					Optional[int]:
 UpperCamelCase      :   List[Any]			      =  [1]
 for i in range(2				,  _lowerCAmelCase	):
  factorials.append(factorials[-1] * i	)
 assert 0 <= k < factorials[-1] * n, "k out of bounds"

 UpperCamelCase      :   Tuple			      =  []
 UpperCamelCase      :   str			      =  list(range(_lowerCAmelCase	)	)

 # Find permutation
 while factorials:
  UpperCamelCase      :   int			      =  factorials.pop()
  UpperCamelCase      ,       UpperCamelCase      :   int			      =  divmod(_lowerCAmelCase				,  _lowerCAmelCase	)
  permutation.append(elements[number]	)
  elements.remove(elements[number]	)
 permutation.append(elements[0]	)

 return permutation


if __name__ == "__main__":
    import doctest

    doctest.testmod()
