





'''simple docstring'''


from __future__ import annotations

from collections.abc import Iterator
from typing import Any
class 				a_       :





     def __init__(			self		: Any     ,				lowercase		: Any						):





           """simple docstring"""




           lowercase_      :Any         =			data
           lowercase_      :Node | None         =			None







class 				a_       :





     def __init__(			self		: Optional[int]						):





           """simple docstring"""




           lowercase_      :Tuple         =			None
           lowercase_      :Any         =			None





     def __iter__(			self		: Dict						):





           """simple docstring"""




           lowercase_      :List[Any]         =			self.head
           while self.head:
                 yield node.data
                 lowercase_      :List[Any]         =			node.next
                 if node == self.head:
                       break





     def __len__(			self		: Dict						):





           """simple docstring"""




           return sum(1 for _ in self						)





     def __repr__(			self		: Dict						):





           """simple docstring"""




           return "->".join(str(snake_case_						) for item in iter(self						)						)





     def 							lowercase__				(			self		: List[str]     ,				lowercase		: Any						):





           """simple docstring"""




           self.insert_nth(len(self						)     ,				snake_case_						)





     def 							lowercase__				(			self		: int     ,				lowercase		: Any						):





           """simple docstring"""




           self.insert_nth(0     ,				snake_case_						)





     def 							lowercase__				(			self		: Tuple     ,				lowercase		: int     ,				lowercase		: Any						):





           """simple docstring"""




           if index < 0 or index > len(self						):
                 raise IndexError("list index out of range."						)
           lowercase_      :str         =			Node(snake_case_						)
           if self.head is None:
                 lowercase_      :Any         =			new_node  # first node points itself
                 lowercase_      :Optional[Any]         =			new_node
           elif index == 0:  # insert at head
                 lowercase_      :Dict         =			self.head
                 lowercase_      :str         =			new_node
           else:
                 lowercase_      :Dict         =			self.head
                 for _ in range(index - 1						):
                       lowercase_      :Any         =			temp.next
                 lowercase_      :List[str]         =			temp.next
                 lowercase_      :Dict         =			new_node
                 if index == len(self						) - 1:  # insert at tail
                       lowercase_      :Dict         =			new_node





     def 							lowercase__				(			self		: Union[str, Any]						):





           """simple docstring"""




           return self.delete_nth(0						)





     def 							lowercase__				(			self		: int						):





           """simple docstring"""




           return self.delete_nth(len(self						) - 1						)





     def 							lowercase__				(			self		: Optional[Any]     ,				lowercase		: int = 0						):





           """simple docstring"""




           if not 0 <= index < len(self						):
                 raise IndexError("list index out of range."						)
           lowercase_      :List[Any]         =			self.head
           if self.head == self.tail:  # just one node
                 lowercase_      :Any         =			None
           elif index == 0:  # delete head node
                 lowercase_      :int         =			self.tail.next.next
                 lowercase_      :List[Any]         =			self.head.next
           else:
                 lowercase_      :List[str]         =			self.head
                 for _ in range(index - 1						):
                       lowercase_      :Union[str, Any]         =			temp.next
                 lowercase_      :List[str]         =			temp.next
                 lowercase_      :Dict         =			temp.next.next
                 if index == len(self						) - 1:  # delete at tail
                       lowercase_      :List[Any]         =			temp
           return delete_node.data







     def 							lowercase__				(			self		: List[Any]						):





           """simple docstring"""




           return len(self						) == 0







def 							UpperCAmelCase_  (						):
      lowercase_      :Tuple         =			CircularLinkedList()
      assert len(lowerCAmelCase__			) == 0
      assert circular_linked_list.is_empty() is True
      assert str(lowerCAmelCase__			) == ""

      try:
            circular_linked_list.delete_front()
            raise AssertionError  # This should not happen
      except IndexError:
            assert True  # This should happen

      try:
            circular_linked_list.delete_tail()
            raise AssertionError  # This should not happen
      except IndexError:
            assert True  # This should happen

      try:
            circular_linked_list.delete_nth(-1			)
            raise AssertionError
      except IndexError:
            assert True

      try:
            circular_linked_list.delete_nth(0			)
            raise AssertionError
      except IndexError:
            assert True

      assert circular_linked_list.is_empty() is True
      for i in range(5			):
            assert len(lowerCAmelCase__			) == i
            circular_linked_list.insert_nth(lowerCAmelCase__     ,i + 1			)
      assert str(lowerCAmelCase__			) == "->".join(str(lowerCAmelCase__			) for i in range(1     ,6			)			)

      circular_linked_list.insert_tail(6			)
      assert str(lowerCAmelCase__			) == "->".join(str(lowerCAmelCase__			) for i in range(1     ,7			)			)
      circular_linked_list.insert_head(0			)
      assert str(lowerCAmelCase__			) == "->".join(str(lowerCAmelCase__			) for i in range(0     ,7			)			)

      assert circular_linked_list.delete_front() == 0
      assert circular_linked_list.delete_tail() == 6
      assert str(lowerCAmelCase__			) == "->".join(str(lowerCAmelCase__			) for i in range(1     ,6			)			)
      assert circular_linked_list.delete_nth(2			) == 3

      circular_linked_list.insert_nth(2     ,3			)
      assert str(lowerCAmelCase__			) == "->".join(str(lowerCAmelCase__			) for i in range(1     ,6			)			)

      assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
 import doctest

 doctest.testmod()









'''simple docstring'''


from abc import ABC, abstractmethod
from argparse import ArgumentParser
class 				a_       (    _lowerCAmelCase							):





     @staticmethod
     @abstractmethod
     def 							lowercase__				(			lowercase		: ArgumentParser						):





        """simple docstring"""




        raise NotImplementedError()







     @abstractmethod
     def 							lowercase__				(			self		: str						):





        """simple docstring"""




        raise NotImplementedError()


