




class 		__UpperCAmelCase:





     """simple docstring"""



     class 		__UpperCAmelCase:





          """simple docstring"""



          __UpperCAmelCase						:			Tuple							=     """_prev""", """_data""", """_next"""

          def __init__(   self			:							List[str]    ,					A			:							int    ,					A			:							Optional[Any]    ,					A			:							int     )      ->      Optional[Any]:






              """simple docstring"""
              a__  			=							link_p
              a__  			=							element
              a__  			=							link_n






          def 					__SCREAMING_SNAKE_CASE		(   self			:							Tuple     )      ->      str:






              """simple docstring"""
              return (
                  f""" Prev -> {self._prev is not None}, Next -> {self._next is not None}"""
              )






     def __init__(   self			:							Optional[Any]     )      ->      int:






         """simple docstring"""
         a__  			=							self._Node(A    ,					A    ,					A     )
         a__  			=							self._Node(A    ,					A    ,					A     )
         a__  			=							self._trailer
         a__  			=							self._header
         a__  			=							0

     def __len__(   self			:							List[str]     )      ->      Union[str, Any]:






         """simple docstring"""
         return self._size

     def 					__SCREAMING_SNAKE_CASE		(   self			:							str     )      ->      Dict:






         """simple docstring"""
         return self.__len__() == 0

     def 					__SCREAMING_SNAKE_CASE		(   self			:							int    ,					A			:							Optional[Any]    ,					A			:							Tuple    ,					A			:							Tuple     )      ->      List[Any]:






         """simple docstring"""
         # Create new_node by setting it's prev.link -> header
         # setting it's next.link -> trailer
         a__  			=							self._Node(A    ,					A    ,					A     )
         a__  			=							new_node
         a__  			=							new_node
         self._size += 1
         return self






     def 					__SCREAMING_SNAKE_CASE		(   self			:							Tuple    ,					A			:							List[str]     )      ->      Tuple:






         """simple docstring"""
         a__  			=							node._prev
         a__  			=							node._next

         a__  			=							successor
         a__  			=							predecessor
         self._size -= 1
         a__  			=							node._data
         a__  			=							a__  			=							a__  			=							None
         del node
         return temp







class 		__UpperCAmelCase(		_DoublyLinkedBase			):





     """simple docstring"""



     def 					__SCREAMING_SNAKE_CASE		(   self			:							int     )      ->      Optional[int]:






         """simple docstring"""
         if self.is_empty():
             raise Exception("""List is empty"""     )
         return self._header._next._data

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Tuple     )      ->      str:






         """simple docstring"""
         if self.is_empty():
             raise Exception("""List is empty"""     )
         return self._trailer._prev._data

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Tuple    ,					A			:							Optional[Any]     )      ->      Union[str, Any]:






         """simple docstring"""
         return self._insert(self._header    ,					A    ,					self._header._next     )

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Dict    ,					A			:							Optional[Any]     )      ->      str:






         """simple docstring"""
         return self._insert(self._trailer._prev    ,					A    ,					self._trailer     )

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Any     )      ->      Any:






         """simple docstring"""
         if self.is_empty():
             raise IndexError("""remove_first from empty list"""     )
         return self._delete(self._header._next     )






     def 					__SCREAMING_SNAKE_CASE		(   self			:							Any     )      ->      List[str]:






         """simple docstring"""
         if self.is_empty():
             raise IndexError("""remove_first from empty list"""     )
         return self._delete(self._trailer._prev     )












from __future__ import annotations

from typing import Generic, TypeVar

SCREAMING_SNAKE_CASE_    :       List[str]       =							TypeVar('''T''')







class 		__UpperCAmelCase(		lowercase__			):





     """simple docstring"""



     pass







class 		__UpperCAmelCase(		lowercase__			):





     """simple docstring"""



     pass







class 		__UpperCAmelCase(		Generic[T]			):





     """simple docstring"""



     def __init__(   self			:							str    ,					A			:							int = 10     )      ->      str:






         """simple docstring"""
         a__  			=							[]
         a__  			=							limit

     def __bool__(   self			:							Dict     )      ->      bool:






         """simple docstring"""
         return bool(self.stack     )

     def __str__(   self			:							str     )      ->      str:






         """simple docstring"""
         return str(self.stack     )

     def 					__SCREAMING_SNAKE_CASE		(   self			:							List[str]    ,					A			:							T     )      ->      None:






         """simple docstring"""
         if len(self.stack     ) >= self.limit:
             raise StackOverflowError
         self.stack.append(A     )

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Any     )      ->      T:






         """simple docstring"""
         if not self.stack:
             raise StackUnderflowError
         return self.stack.pop()

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Optional[int]     )      ->      T:






         """simple docstring"""
         if not self.stack:
             raise StackUnderflowError
         return self.stack[-1]

     def 					__SCREAMING_SNAKE_CASE		(   self			:							str     )      ->      bool:






         """simple docstring"""
         return not bool(self.stack     )

     def 					__SCREAMING_SNAKE_CASE		(   self			:							Dict     )      ->      bool:






         """simple docstring"""
         return self.size() == self.limit

     def 					__SCREAMING_SNAKE_CASE		(   self			:							int     )      ->      int:






         """simple docstring"""
         return len(self.stack     )






     def __contains__(   self			:							int    ,					A			:							T     )      ->      bool:






         """simple docstring"""
         return item in self.stack






def 							__lowerCAmelCase			():
    a__  			=							Stack(10		)
    assert bool(UpperCAmelCase_		) is False
    assert stack.is_empty() is True
    assert stack.is_full() is False
    assert str(UpperCAmelCase_		) == "[]"

    try:
        a__  			=							stack.pop()
        raise AssertionError  # This should not happen
    except StackUnderflowError:
        assert True  # This should happen

    try:
        a__  			=							stack.peek()
        raise AssertionError  # This should not happen
    except StackUnderflowError:
        assert True  # This should happen

    for i in range(10		):
        assert stack.size() == i
        stack.push(UpperCAmelCase_		)

    assert bool(UpperCAmelCase_		)
    assert not stack.is_empty()
    assert stack.is_full()
    assert str(UpperCAmelCase_		) == str(list(range(10		)		)		)
    assert stack.pop() == 9
    assert stack.peek() == 8

    stack.push(100		)
    assert str(UpperCAmelCase_		) == str([0, 1, 2, 3, 4, 5, 6, 7, 8, 100]		)

    try:
        stack.push(200		)
        raise AssertionError  # This should not happen
    except StackOverflowError:
        assert True  # This should happen

    assert not stack.is_empty()
    assert stack.size() == 10

    assert 5 in stack
    assert 55 not in stack


if __name__ == "__main__":
 test_stack()






