



from __future__ import annotations

from collections import Counter


def 						UpperCAmelCase__   (   UpperCAmelCase__			:int       ):






 '''simple docstring'''

 a							=		[True] * n
 a							=		False
 a							=		False
 a							=		True

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

 a							=		[2]

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

 return primes


def 						UpperCAmelCase__   (   UpperCAmelCase__			:int       ):






 '''simple docstring'''

 a							=		str(UpperCAmelCase__       )
 a							=		[]
 a							=		["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

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

 return replacements


def 						UpperCAmelCase__   (   UpperCAmelCase__			:int = 8       ):






 '''simple docstring'''

 a							=		set()

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

 for prime in primes:
  if prime in numbers_checked:
   continue

  a							=		digit_replacements(UpperCAmelCase__       )

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

   if len(UpperCAmelCase__       ) != family_length:
    continue

   return min(UpperCAmelCase__       )

 return -1


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








def  __UpperCamelCase   (     a = 998001)			->int:

					# fetches the next number
					for number in range(n - 1,  9999,  -1):
										lowerCamelCase__      =							str(a)

										# checks whether 'str_number' is a palindrome.
										if str_number == str_number[::-1]:
															lowerCamelCase__      =							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() = }""")

