





"""simple docstring"""




from __future__ import annotations

from typing import Generic, TypeVar

UpperCamelCase_	 =TypeVar("""T""")




class 					_a		( Generic[T]							):






				def __init__(					self						:       str,					lowerCAmelCase__						:       T				)      -> Optional[Any]:




										'''simple docstring'''



										_UpperCamelCase     :   str      =       data  # Assign data
										_UpperCamelCase     :   Node[T] | None      =       None  # Initialize next as null
										_UpperCamelCase     :   Node[T] | None      =       None  # Initialize prev as null




class 					_a		( Generic[T]							):






				def __init__(					self						:       Dict				)      -> None:




										'''simple docstring'''



										_UpperCamelCase     :   Node[T] | None      =       None






				def 							snake_case      (					self						:       Union[str, Any],					lowerCAmelCase__						:       T				)      -> None:




										'''simple docstring'''



										if self.head is None:
																_UpperCamelCase     :   Tuple      =       Node(lowerCAmelCase__				)
										else:
																_UpperCamelCase     :   str      =       Node(lowerCAmelCase__				)
																_UpperCamelCase     :   List[str]      =       new_node
																_UpperCamelCase     :   Union[str, Any]      =       self.head
																_UpperCamelCase     :   str      =       None
																_UpperCamelCase     :   Optional[Any]      =       new_node






				def 							snake_case      (					self						:       int				)      -> T | None:




										'''simple docstring'''



										if self.head is None:
																return None
										else:
																assert self.head is not None
																_UpperCamelCase     :   Optional[int]      =       self.head.data
																_UpperCamelCase     :   Optional[int]      =       self.head.next
																if self.head is not None:
																						_UpperCamelCase     :   List[Any]      =       None
																return temp






				def 							snake_case      (					self						:       Dict				)      -> T | None:




										'''simple docstring'''



										return self.head.data if self.head is not None else None






				def __len__(					self						:       Optional[int]				)      -> int:




										'''simple docstring'''



										_UpperCamelCase     :   Dict      =       self.head
										_UpperCamelCase     :   Optional[Any]      =       0
										while temp is not None:
																count += 1
																_UpperCamelCase     :   int      =       temp.next
										return count






				def 							snake_case      (					self						:       List[Any]				)      -> bool:




										'''simple docstring'''



										return self.head is None






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




										'''simple docstring'''



										print('''stack elements are:'''				)
										_UpperCamelCase     :   Optional[int]      =       self.head
										while temp is not None:
																print(temp.data,					end='''->'''				)
																_UpperCamelCase     :   List[str]      =       temp.next


# Code execution starts here
if __name__ == "__main__":
						# Start with the empty stack
						UpperCamelCase_	 =Stack()

						# Insert 4 at the beginning. So stack becomes 4->None
						print("""Stack operations using Doubly LinkedList""")
						stack.push(4)

						# Insert 5 at the beginning. So stack becomes 4->5->None
						stack.push(5)

						# Insert 6 at the beginning. So stack becomes 4->5->6->None
						stack.push(6)

						# Insert 7 at the beginning. So stack becomes 4->5->6->7->None
						stack.push(7)

						# Print the stack
						stack.print_stack()

						# Print the top element
						print("""\nTop element is """, stack.top())

						# Print the stack size
						print("""Size of the stack is """, len(stack))

						# pop the top element
						stack.pop()

						# pop the top element
						stack.pop()

						# two elements have now been popped off
						stack.print_stack()

						# Print True if the stack is empty else False
						print("""\nstack is empty:""", stack.is_empty())








'''simple docstring'''





def     UpperCAmelCase     (    a_ = 9_9_8_0_0_1		)   ->       int:



   """simple docstring"""






   for number in range(n - 1      ,		9_9_9_9      ,		-1		):
      A_  :		Optional[Any]						=					str(a_		)

      # checks whether 'str_number' is a palindrome.
      if str_number == str_number[::-1]:
         A_  :		int						=					9_9_9

         # if 'number' is a product of two 3-digit numbers
         # then number is the answer otherwise fetch next number.
         while divisor != 9_9:
            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() = }')
