"""simple docstring"""







from __future__ import annotations

from typing import Generic, TypeVar

UpperCamelCase_    :    Union[str, Any]											=						TypeVar("""T""")


class      _lowercase						(				Generic[T]					):

				def __init__(       self    :      int    ,      _lowercase    :      T       ):


										'''simple docstring'''
										UpperCAmelCase__   		=						data  # Assign data
										UpperCAmelCase__   		=						None  # Initialize next as null
										UpperCAmelCase__   		=						None  # Initialize prev as null


class      _lowercase						(				Generic[T]					):

				def __init__(       self    :      Tuple       ):


										'''simple docstring'''
										UpperCAmelCase__   		=						None

				def     A	(       self    :      List[Any]    ,      _lowercase    :      T       ):


										'''simple docstring'''
										if self.head is None:
																UpperCAmelCase__   		=						Node(_lowercase       )
										else:
																UpperCAmelCase__   		=						Node(_lowercase       )
																UpperCAmelCase__   		=						new_node
																UpperCAmelCase__   		=						self.head
																UpperCAmelCase__   		=						None
																UpperCAmelCase__   		=						new_node

				def     A	(       self    :      List[str]       ):


										'''simple docstring'''
										if self.head is None:
																return None
										else:
																assert self.head is not None
																UpperCAmelCase__   		=						self.head.data
																UpperCAmelCase__   		=						self.head.next
																if self.head is not None:
																						UpperCAmelCase__   		=						None
																return temp

				def     A	(       self    :      List[Any]       ):


										'''simple docstring'''
										return self.head.data if self.head is not None else None

				def __len__(       self    :      Optional[Any]       ):


										'''simple docstring'''
										UpperCAmelCase__   		=						self.head
										UpperCAmelCase__   		=						0
										while temp is not None:
																count += 1
																UpperCAmelCase__   		=						temp.next
										return count

				def     A	(       self    :      Any       ):


										'''simple docstring'''
										return self.head is None

				def     A	(       self    :      List[Any]       ):


										'''simple docstring'''
										print("""stack elements are:"""       )
										UpperCAmelCase__   		=						self.head
										while temp is not None:
																print(temp.data    ,      end="""->"""       )
																UpperCAmelCase__   		=						temp.next


# Code execution starts here
if __name__ == "__main__":
						# Start with the empty stack
						UpperCamelCase_    :    Stack[int]											=						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"""







from __future__ import annotations

from collections import Counter


def 					a__ (						UpperCAmelCase__    :     int     )->		list[int]:
						UpperCAmelCase__   		=						[True] * n
						UpperCAmelCase__   		=						False
						UpperCAmelCase__   		=						False
						UpperCAmelCase__   		=						True

						for i in range(3						,     int(n**0.5 + 1     )						,     2     ):
												UpperCAmelCase__   		=						i * 2
												while index < n:
																		UpperCAmelCase__   		=						False
																		UpperCAmelCase__   		=						index + i

						UpperCAmelCase__   		=						[2]

						for i in range(3						,     UpperCAmelCase__						,     2     ):
												if is_prime[i]:
																		primes.append(UpperCAmelCase__     )

						return primes


def 					a__ (						UpperCAmelCase__    :     int     )->		list[list[int]]:
						UpperCAmelCase__   		=						str(UpperCAmelCase__     )
						UpperCAmelCase__   		=						[]
						UpperCAmelCase__   		=						["""0""", """1""", """2""", """3""", """4""", """5""", """6""", """7""", """8""", """9"""]

						for duplicate in Counter(UpperCAmelCase__     ) - Counter(set(UpperCAmelCase__     )     ):
												UpperCAmelCase__   		=						[int(number_str.replace(UpperCAmelCase__						,     UpperCAmelCase__     )     ) for digit in digits]
												replacements.append(UpperCAmelCase__     )

						return replacements


def 					a__ (						UpperCAmelCase__    :     int = 8     )->		int:
						UpperCAmelCase__   		=						set()

						# Filter primes with less than 3 replaceable digits
						UpperCAmelCase__   		=						{
						    x for x in set(prime_sieve(1_0_0_0_0_0_0     )     ) if len(str(UpperCAmelCase__     )     ) - len(set(str(UpperCAmelCase__     )     )     ) >= 3
						}

						for prime in primes:
												if prime in numbers_checked:
																		continue

												UpperCAmelCase__   		=						digit_replacements(UpperCAmelCase__     )

												for family in replacements:
																		numbers_checked.update(UpperCAmelCase__     )
																		UpperCAmelCase__   		=						primes.intersection(UpperCAmelCase__     )

																		if len(UpperCAmelCase__     ) != family_length:
																								continue

																		return min(UpperCAmelCase__     )

						return -1


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

