
'''simple docstring'''
from __future__ import annotations

from collections import Counter

def 				UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Dict            =  [True] * n
    snake_case_	:      List[Any]            =  False
    snake_case_	:      List[str]            =  False
    snake_case_	:      Union[str, Any]            =  True

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

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

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

    return primes

def 				UpperCamelCase_       (		__SCREAMING_SNAKE_CASE    ):
    """simple docstring"""






    snake_case_	:      Union[str, Any]            =  str(__SCREAMING_SNAKE_CASE    )
    snake_case_	:      List[Any]            =  []
    snake_case_	:      str            =  ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]

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

    return replacements

def 				UpperCamelCase_       (		__SCREAMING_SNAKE_CASE = 8    ):
    """simple docstring"""






    snake_case_	:      List[str]            =  set()

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

    for prime in primes:
        if prime in numbers_checked:
            continue

        snake_case_	:      Any            =  digit_replacements(__SCREAMING_SNAKE_CASE    )

        for family in replacements:
            numbers_checked.update(__SCREAMING_SNAKE_CASE    )
            snake_case_	:      Tuple            =  primes.intersection(__SCREAMING_SNAKE_CASE    )

            if len(__SCREAMING_SNAKE_CASE    ) != family_length:
                continue

            return min(__SCREAMING_SNAKE_CASE    )

    return -1


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






'''simple docstring'''
from __future__ import annotations

from typing import Any






class 				UpperCAmelCase_			:





 def __init__(      self	,    lowercase_	,    lowercase_):  # noqa: A002
     snake_case_	:      List[str]            =  item
     snake_case_	:      Dict            =  next






class 				UpperCAmelCase_			:





 def __init__(      self):
     snake_case_	:      Node | None            =  None
     snake_case_	:      List[str]            =  0





 def     snake_case__						(      self	,    lowercase_):
     snake_case_	:      List[Any]            =  Node(lowercase_	,    self.head)
     self.size += 1





 def     snake_case__						(      self):
     # Switched 'self.is_empty()' to 'self.head is None'
     # because mypy was considering the possibility that 'self.head'
     # can be None in below else part and giving error
     if self.head is None:
         return None
     else:
         snake_case_	:      List[Any]            =  self.head.item
         snake_case_	:      Any            =  self.head.next
         self.size -= 1
         return item





 def     snake_case__						(      self):
     return self.head is None





 def __str__(      self):
     if self.is_empty():
         return ""
     else:
         snake_case_	:      Dict            =  self.head
         snake_case_	:      Optional[Any]            =  ""
         snake_case_	:      list[str]            =  []
         while iterate:
             item_list.append(str(iterate.item))
             snake_case_	:      List[str]            =  iterate.next

         snake_case_	:      Optional[Any]            =  " --> ".join(lowercase_)

         return item_str





 def __len__(      self):
     return self.size




