


from __future__ import annotations

from enum import Enum



class    __lowercase  (       lowercase__							):

							"""simple docstring"""


							SCREAMING_SNAKE_CASE   :					Any        =						24
							SCREAMING_SNAKE_CASE   :					Tuple        =						21
							SCREAMING_SNAKE_CASE   :					Union[str, Any]        =						18
							SCREAMING_SNAKE_CASE   :					int        =						15
							SCREAMING_SNAKE_CASE   :					List[str]        =						12
							SCREAMING_SNAKE_CASE   :					List[Any]        =						9
							SCREAMING_SNAKE_CASE   :					Tuple        =						6
							SCREAMING_SNAKE_CASE   :					Dict        =						3
							SCREAMING_SNAKE_CASE   :					List[str]        =						2
							SCREAMING_SNAKE_CASE   :					Any        =						1
							SCREAMING_SNAKE_CASE   :					List[str]        =						-1
							SCREAMING_SNAKE_CASE   :					List[str]        =						-2
							SCREAMING_SNAKE_CASE   :					Optional[int]        =						-3
							SCREAMING_SNAKE_CASE   :					Tuple        =						-6
							SCREAMING_SNAKE_CASE   :					Dict        =						-9
							SCREAMING_SNAKE_CASE   :					Any        =						-12
							SCREAMING_SNAKE_CASE   :					int        =						-15
							SCREAMING_SNAKE_CASE   :					Any        =						-18
							SCREAMING_SNAKE_CASE   :					Optional[Any]        =						-21
							SCREAMING_SNAKE_CASE   :					Dict        =						-24







class    __lowercase  (       lowercase__							):

							"""simple docstring"""


							SCREAMING_SNAKE_CASE   :					Union[str, Any]        =						8
							SCREAMING_SNAKE_CASE   :					List[str]        =						7
							SCREAMING_SNAKE_CASE   :					str        =						6
							SCREAMING_SNAKE_CASE   :					Tuple        =						5
							SCREAMING_SNAKE_CASE   :					int        =						4
							SCREAMING_SNAKE_CASE   :					int        =						3
							SCREAMING_SNAKE_CASE   :					Dict        =						2
							SCREAMING_SNAKE_CASE   :					List[str]        =						1







def 				SCREAMING_SNAKE_CASE (     UpperCAmelCase__   ,UpperCAmelCase__   ,UpperCAmelCase__   ,):

				"""simple docstring"""






				if isinstance(UpperCAmelCase__   ,UpperCAmelCase__							):
								_SCREAMING_SNAKE_CASE      = SIUnit[known_prefix.lower()]
				if isinstance(UpperCAmelCase__   ,UpperCAmelCase__							):
								_SCREAMING_SNAKE_CASE      = SIUnit[unknown_prefix.lower()]
				_SCREAMING_SNAKE_CASE      = known_amount * (
				    10 ** (known_prefix.value - unknown_prefix.value)
				)
				return unknown_amount


def 				SCREAMING_SNAKE_CASE (     UpperCAmelCase__   ,UpperCAmelCase__   ,UpperCAmelCase__   ,):

				"""simple docstring"""






				if isinstance(UpperCAmelCase__   ,UpperCAmelCase__							):
								_SCREAMING_SNAKE_CASE      = BinaryUnit[known_prefix.lower()]
				if isinstance(UpperCAmelCase__   ,UpperCAmelCase__							):
								_SCREAMING_SNAKE_CASE      = BinaryUnit[unknown_prefix.lower()]
				_SCREAMING_SNAKE_CASE      = known_amount * (
				    2 ** ((known_prefix.value - unknown_prefix.value) * 10)
				)
				return unknown_amount


if __name__ == "__main__":
							import doctest

							doctest.testmod()








from __future__ import annotations

from collections import Counter


def 				SCREAMING_SNAKE_CASE (     UpperCAmelCase__							):

				"""simple docstring"""






				_SCREAMING_SNAKE_CASE      = [True] * n
				_SCREAMING_SNAKE_CASE      = False
				_SCREAMING_SNAKE_CASE      = False
				_SCREAMING_SNAKE_CASE      = True

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

				_SCREAMING_SNAKE_CASE      = [2]

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

				return primes


def 				SCREAMING_SNAKE_CASE (     UpperCAmelCase__							):

				"""simple docstring"""






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

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

				return replacements


def 				SCREAMING_SNAKE_CASE (     UpperCAmelCase__ = 8							):

				"""simple docstring"""






				_SCREAMING_SNAKE_CASE      = set()

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

				for prime in primes:
								if prime in numbers_checked:
												continue

								_SCREAMING_SNAKE_CASE      = digit_replacements(UpperCAmelCase__							)

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

												if len(UpperCAmelCase__							) != family_length:
																continue

												return min(UpperCAmelCase__							)

				return -1


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