





'''simple docstring'''




from __future__ import annotations

from collections.abc import Iterator
from typing import Any


class 			SCREAMING_SNAKE_CASE   :


     def __init__(						self						,     _UpperCAmelCase):

          '''simple docstring'''






          __A						:			Any								=	data
          __A						:			Node | None								=	None




class 			SCREAMING_SNAKE_CASE   :


     def __init__(						self):

          '''simple docstring'''






          __A						:			Any								=	None
          __A						:			Dict								=	None


     def __iter__(						self):

          '''simple docstring'''






          __A						:			Dict								=	self.head
          while self.head:
               yield node.data
               __A						:			List[str]								=	node.next
               if node == self.head:
                    break


     def __len__(						self):

          '''simple docstring'''






          return sum(1 for _ in self)


     def __repr__(						self):

          '''simple docstring'''






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


     def 							SCREAMING_SNAKE_CASE  (						self						,     _UpperCAmelCase):

          '''simple docstring'''






          self.insert_nth(len(self)						,     lowerCAmelCase__)


     def 							SCREAMING_SNAKE_CASE  (						self						,     _UpperCAmelCase):

          '''simple docstring'''






          self.insert_nth(0						,     lowerCAmelCase__)


     def 							SCREAMING_SNAKE_CASE  (						self						,     _UpperCAmelCase						,     _UpperCAmelCase):

          '''simple docstring'''






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


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          return self.delete_nth(0)


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






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


     def 							SCREAMING_SNAKE_CASE  (						self						,     _UpperCAmelCase = 0):

          '''simple docstring'''






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


     def 							SCREAMING_SNAKE_CASE  (						self):

          '''simple docstring'''






          return len(self) == 0






def 	_lowerCAmelCase      (  )					->					Tuple:
     __A						:			int								=	CircularLinkedList()
     assert len(a_      ) == 0
     assert circular_linked_list.is_empty() is True
     assert str(a_      ) == ""

     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(a_      ) == i
          circular_linked_list.insert_nth(a_			,							i + 1      )
     assert str(a_      ) == "->".join(str(a_      ) for i in range(1			,							6      )      )

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

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

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

     assert circular_linked_list.is_empty() is False


if __name__ == "__main__":
  import doctest

  doctest.testmod()






'''simple docstring'''




from __future__ import annotations






def 	_lowerCAmelCase      (  __snake_case  :			list[int | str]      )					->					None:
     create_state_space_tree(__snake_case			,							[]			,							0			,							[0 for i in range(len(__snake_case      )      )]      )






def 	_lowerCAmelCase      (  __snake_case  :			list[int | str]			,							__snake_case  :			list[int | str]			,							__snake_case  :			int			,							__snake_case  :			list[int]			,							)					->					None:

     if index == len(__snake_case      ):
          print(__snake_case      )
          return

     for i in range(len(__snake_case      )      ):
          if not index_used[i]:
               current_sequence.append(sequence[i]      )
               __A						:			Any								=	True
               create_state_space_tree(__snake_case			,							__snake_case			,							index + 1			,							__snake_case      )
               current_sequence.pop()
               __A						:			Any								=	False
lowercase__   :				list[int | str]      =   [3, 1, 2, 4]
generate_all_permutations(sequence)

lowercase__   :				list[int | str]      =   ["A", "B", "C"]







generate_all_permutations(sequence_a)