


'''simple docstring'''


from __future__ import annotations

from collections.abc import Iterator
from typing import Any






class 	lowerCAmelCase__			:




			def __init__(		self  :     Any	,  lowerCamelCase__  :     Any )   ->Union[str, Any]:



					'''simple docstring'''







					_UpperCAmelCase		:       Any								=      data
					_UpperCAmelCase		:       Node | None								=      None






class 	lowerCAmelCase__			:




			def __init__(		self  :     int )   ->Any:



					'''simple docstring'''







					_UpperCAmelCase		:       str								=      None
					_UpperCAmelCase		:       Any								=      None




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



					'''simple docstring'''







					_UpperCAmelCase		:       Tuple								=      self.head
					while self.head:
							yield node.data
							_UpperCAmelCase		:       Optional[int]								=      node.next
							if node == self.head:
									break




			def __len__(		self  :     Any )   ->int:



					'''simple docstring'''







					return sum(1 for _ in self )




			def __repr__(		self  :     int )   ->str:



					'''simple docstring'''







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




			def 							lowerCAmelCase__    (		self  :     Any	,  lowerCamelCase__  :     Any )   ->None:



					'''simple docstring'''







					self.insert_nth(len(self )	,  lowerCamelCase__ )




			def 							lowerCAmelCase__    (		self  :     List[str]	,  lowerCamelCase__  :     Any )   ->None:



					'''simple docstring'''







					self.insert_nth(0	,  lowerCamelCase__ )




			def 							lowerCAmelCase__    (		self  :     Dict	,  lowerCamelCase__  :     int	,  lowerCamelCase__  :     Any )   ->None:



					'''simple docstring'''







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




			def 							lowerCAmelCase__    (		self  :     Tuple )   ->List[Any]:



					'''simple docstring'''







					return self.delete_nth(0 )




			def 							lowerCAmelCase__    (		self  :     Optional[Any] )   ->Any:



					'''simple docstring'''







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




			def 							lowerCAmelCase__    (		self  :     Optional[Any]	,  lowerCamelCase__  :     int = 0 )   ->Any:



					'''simple docstring'''







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






			def 							lowerCAmelCase__    (		self  :     Tuple )   ->bool:



					'''simple docstring'''







					return len(self ) == 0






def  __lowerCAmelCase ():
		_UpperCAmelCase		:       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'''


def  __lowerCAmelCase ():
		_UpperCAmelCase		:       str								=      0
		for i in range(1      , 1_001   ):
				total += i**i
		return str(__lowerCAmelCase   )[-10:]


if __name__ == "__main__":
						print(solution())



