






from __future__ import annotations

from collections import Counter
def    a__    (	A       ):
   lowercase__    :						Optional[Any]       =			[True] * n
   lowercase__    :						Optional[Any]       =			False
   lowercase__    :						List[Any]       =			False
   lowercase__    :						Optional[int]       =			True

   for i in range(3		,					int(n**0.5 + 1       )		,					2       ):
      lowercase__    :						Optional[int]       =			i * 2
      while index < n:
         lowercase__    :						Any       =			False
         lowercase__    :						int       =			index + i

   lowercase__    :						Union[str, Any]       =			[2]

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

   return primes
def    a__    (	A       ):
   lowercase__    :						Dict       =			str(A       )
   lowercase__    :						str       =			[]
   lowercase__    :						Union[str, Any]       =			["""0""", """1""", """2""", """3""", """4""", """5""", """6""", """7""", """8""", """9"""]

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

   return replacements
def    a__    (	A = 8       ):
   lowercase__    :						List[str]       =			set()

   # Filter primes with less than 3 replaceable digits
   lowercase__    :						int       =			{
       x for x in set(prime_sieve(1_000_000       )       ) if len(str(A       )       ) - len(set(str(A       )       )       ) >= 3
   }

   for prime in primes:
      if prime in numbers_checked:
         continue

      lowercase__    :						List[Any]       =			digit_replacements(A       )

      for family in replacements:
         numbers_checked.update(A       )
         lowercase__    :						Any       =			primes.intersection(A       )

         if len(A       ) != family_length:
            continue

         return min(A       )

   return -1


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










def    a__    (	A       ):
   return " ".join([word[::-1] for word in input_str.split()]       )


if __name__ == "__main__":
 import doctest

 doctest.testmod()


