

class  __a				:





       """simple docstring"""


       def __init__(      self ,				snake_case      ):





        """simple docstring"""

        lowerCAmelCase__      :							List[Any]    =							data
        lowerCAmelCase__      :							Tuple    =							None
        lowerCAmelCase__      :							List[str]    =							None






       def __str__(      self      ):





        """simple docstring"""

        return F"""{self.data}"""






class  __a				:





       """simple docstring"""


       def __init__(      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Any    =							None
        lowerCAmelCase__      :							Any    =							None






       def __iter__(      self      ):





        """simple docstring"""

        lowerCAmelCase__      :							Optional[Any]    =							self.head
        while node:
         yield node.data
         lowerCAmelCase__      :							int    =							node.next






       def __str__(      self      ):





        """simple docstring"""

        return "->".join([str(a_      ) for item in self]      )






       def __len__(      self      ):





        """simple docstring"""

        return sum(1 for _ in self      )






       def  SCREAMING_SNAKE_CASE_  (      self ,				snake_case      ):





        """simple docstring"""

        self.insert_at_nth(0 ,				a_      )






       def  SCREAMING_SNAKE_CASE_  (      self ,				snake_case      ):





        """simple docstring"""

        self.insert_at_nth(len(self      ) ,				a_      )






       def  SCREAMING_SNAKE_CASE_  (      self ,				snake_case ,				snake_case      ):





        """simple docstring"""

        lowerCAmelCase__      :							Dict    =							len(self      )

        if not 0 <= index <= length:
         raise IndexError("list index out of range"      )
        lowerCAmelCase__      :							int    =							Node(a_      )
        if self.head is None:
         lowerCAmelCase__      :							Dict    =							new_node
        elif index == 0:
         lowerCAmelCase__      :							Dict    =							new_node
         lowerCAmelCase__      :							Dict    =							self.head
         lowerCAmelCase__      :							Dict    =							new_node
        elif index == length:
         lowerCAmelCase__      :							int    =							new_node
         lowerCAmelCase__      :							Union[str, Any]    =							self.tail
         lowerCAmelCase__      :							List[Any]    =							new_node
        else:
         lowerCAmelCase__      :							List[str]    =							self.head
         for _ in range(0 ,				a_      ):
          lowerCAmelCase__      :							List[str]    =							temp.next
         lowerCAmelCase__      :							Tuple    =							new_node
         lowerCAmelCase__      :							Any    =							temp.previous
         lowerCAmelCase__      :							List[Any]    =							temp
         lowerCAmelCase__      :							Tuple    =							new_node






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        return self.delete_at_nth(0      )






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

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






       def  SCREAMING_SNAKE_CASE_  (      self ,				snake_case      ):





        """simple docstring"""

        lowerCAmelCase__      :							List[str]    =							len(self      )

        if not 0 <= index <= length - 1:
         raise IndexError("list index out of range"      )
        lowerCAmelCase__      :							Optional[Any]    =							self.head  # default first node
        if length == 1:
         lowerCAmelCase__      :							Dict    =							None
        elif index == 0:
         lowerCAmelCase__      :							Dict    =							self.head.next
         lowerCAmelCase__      :							Optional[Any]    =							None
        elif index == length - 1:
         lowerCAmelCase__      :							Union[str, Any]    =							self.tail
         lowerCAmelCase__      :							List[Any]    =							self.tail.previous
         lowerCAmelCase__      :							Any    =							None
        else:
         lowerCAmelCase__      :							Optional[Any]    =							self.head
         for _ in range(0 ,				a_      ):
          lowerCAmelCase__      :							List[Any]    =							temp.next
         lowerCAmelCase__      :							int    =							temp
         lowerCAmelCase__      :							str    =							temp.previous
         lowerCAmelCase__      :							Optional[Any]    =							temp.next
        return delete_node.data






       def  SCREAMING_SNAKE_CASE_  (      self ,				snake_case      ):





        """simple docstring"""

        lowerCAmelCase__      :							Optional[Any]    =							self.head

        while current.data != data:  # Find the position to delete
         if current.next:
          lowerCAmelCase__      :							Tuple    =							current.next
         else:  # We have reached the end an no value matches
          raise ValueError("No data matching given value"      )

        if current == self.head:
         self.delete_head()

        elif current == self.tail:
         self.delete_tail()

        else:  # Before: 1 <--> 2(current) <--> 3
         lowerCAmelCase__      :							Optional[Any]    =							current.next  # 1 --> 3
         lowerCAmelCase__      :							str    =							current.previous  # 1 <--> 3
        return data






       def  SCREAMING_SNAKE_CASE_  (      self      ):





        """simple docstring"""

        return len(self      ) == 0




def 			SCREAMING_SNAKE_CASE       (   ) ->	Union[str, Any]:
 lowerCAmelCase__      :							List[str]    =							DoublyLinkedList()
 assert linked_list.is_empty() is True
 assert str(UpperCamelCase__      ) == ""

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

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

 for i in range(1_0      ):
  assert len(UpperCamelCase__      ) == i
  linked_list.insert_at_nth(UpperCamelCase__				,				i + 1      )
 assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(1				,				1_1      )      )

 linked_list.insert_at_head(0      )
 linked_list.insert_at_tail(1_1      )
 assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(0				,				1_2      )      )

 assert linked_list.delete_head() == 0
 assert linked_list.delete_at_nth(9      ) == 1_0
 assert linked_list.delete_tail() == 1_1
 assert len(UpperCamelCase__      ) == 9
 assert str(UpperCamelCase__      ) == "->".join(str(UpperCamelCase__      ) for i in range(1				,				1_0      )      )


if __name__ == "__main__":
    from doctest import testmod

    testmod()









"""simple docstring"""

def 			SCREAMING_SNAKE_CASE       (   lowercase__      ) ->	int:
 return 1 if input_a == 0 else 0



def 			SCREAMING_SNAKE_CASE       (   ) ->	None:
 assert not_gate(0      ) == 1
 assert not_gate(1      ) == 0


if __name__ == "__main__":
    print(not_gate(0))
    print(not_gate(1))






