
"""simple docstring"""







class 		UpperCAmelCase_	:
 """simple docstring"""




 def __init__( self       : List[str]     ,   a_       : List[Any] )->					Any:



      """simple docstring"""

      UpperCAmelCase_						:    Optional[int]    					=  data
      UpperCAmelCase_						:    List[str]    					=  None
      UpperCAmelCase_						:    int    					=  None






 def __str__( self       : Tuple )->					Union[str, Any]:



      """simple docstring"""

      return f'''{self.data}'''



class 		UpperCAmelCase_	:
 """simple docstring"""




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



      """simple docstring"""

      UpperCAmelCase_						:    Any    					=  None
      UpperCAmelCase_						:    Union[str, Any]    					=  None




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



      """simple docstring"""

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




 def __str__( self       : int )->					int:



      """simple docstring"""

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




 def __len__( self       : Tuple )->					Dict:



      """simple docstring"""

      return sum(1 for _ in self )




 def   a      ( self       : str     ,   a_       : Any )->					Tuple:



      """simple docstring"""

      self.insert_at_nth(0     ,   a_ )




 def   a      ( self       : Optional[int]     ,   a_       : List[str] )->					List[Any]:



      """simple docstring"""

      self.insert_at_nth(len(self )     ,   a_ )




 def   a      ( self       : List[Any]     ,   a_       : int     ,   a_       : Tuple )->					str:



      """simple docstring"""

      UpperCAmelCase_						:    Dict    					=  len(self )

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




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



      """simple docstring"""

      return self.delete_at_nth(0 )




 def   a      ( self       : Optional[int] )->					Union[str, Any]:



      """simple docstring"""

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




 def   a      ( self       : Dict     ,   a_       : int )->					Union[str, Any]:



      """simple docstring"""

      UpperCAmelCase_						:    List[Any]    					=  len(self )

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




 def   a      ( self       : int     ,   a_       : str )->					str:



      """simple docstring"""

      UpperCAmelCase_						:    Dict    					=  self.head

      while current.data != data:  # Find the position to delete
           if current.next:
                UpperCAmelCase_						:    Union[str, Any]    					=  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
           UpperCAmelCase_						:    int    					=  current.next  # 1 --> 3
           UpperCAmelCase_						:    str    					=  current.previous  # 1 <--> 3
      return data






 def   a      ( self       : Union[str, Any] )->					Dict:



      """simple docstring"""

      return len(self ) == 0




def 			A_			(					)     ->							None:


     """simple docstring"""







     UpperCAmelCase_						:    List[Any]    					=  DoublyLinkedList()
     assert linked_list.is_empty() is True
     assert str(lowercase      ) == ""

     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(10      ):
          assert len(lowercase      ) == i
          linked_list.insert_at_nth(lowercase						, i + 1      )
     assert str(lowercase      ) == "->".join(str(lowercase      ) for i in range(1						, 11      )      )

     linked_list.insert_at_head(0      )
     linked_list.insert_at_tail(11      )
     assert str(lowercase      ) == "->".join(str(lowercase      ) for i in range(0						, 12      )      )

     assert linked_list.delete_head() == 0
     assert linked_list.delete_at_nth(9      ) == 10
     assert linked_list.delete_tail() == 11
     assert len(lowercase      ) == 9
     assert str(lowercase      ) == "->".join(str(lowercase      ) for i in range(1						, 10      )      )


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

       testmod()



"""simple docstring"""







def 			A_			(					lowercase = 99_8001      )     ->							int:


     """simple docstring"""







     for number in range(n - 1						, 9999						, -1      ):
          UpperCAmelCase_						:    Union[str, Any]    					=  str(lowercase      )

          # checks whether 'str_number' is a palindrome.
          if str_number == str_number[::-1]:
               UpperCAmelCase_						:    List[str]    					=  999

               # if 'number' is a product of two 3-digit numbers
               # then number is the answer otherwise fetch next number.
               while divisor != 99:
                    if (number % divisor == 0) and (len(str(number // divisor      )      ) == 3.0):
                         return number
                    divisor -= 1
     raise ValueError("""That number is larger than our acceptable range."""      )


if __name__ == "__main__":
       print(f"""{solution() = }""")

