




'''simple docstring'''




from __future__ import annotations

from collections import Counter

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      List[Any]       ):
	'''simple docstring'''





	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       ,						snake_case_       ,						2       ):
		if is_prime[i]:
			primes.append(snake_case_       )

	return primes

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Optional[int]       ):
	'''simple docstring'''





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

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

	return replacements

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      Union[str, Any] = 8       ):
	'''simple docstring'''





	UpperCAmelCase__										=    set()

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

	for prime in primes:
		if prime in numbers_checked:
			continue

		UpperCAmelCase__										=    digit_replacements(snake_case_       )

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

			if len(snake_case_       ) != family_length:
				continue

			return min(snake_case_       )

	return -1


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






'''simple docstring'''




from collections import namedtuple

UpperCAmelCase_       				=      namedtuple('from_to', 'from_ to')

UpperCAmelCase_       				=      {
    'millimeter': 'mm',
    'centimeter': 'cm',
    'meter': 'm',
    'kilometer': 'km',
    'inch': 'in',
    'inche': 'in',  # Trailing 's' has been stripped off
    'feet': 'ft',
    'foot': 'ft',
    'yard': 'yd',
    'mile': 'mi',
}

UpperCAmelCase_       				=      {
    'mm': from_to(0.001, 1_0_0_0),
    'cm': from_to(0.01, 1_0_0),
    'm': from_to(1, 1),
    'km': from_to(1_0_0_0, 0.001),
    'in': from_to(0.0254, 39.3701),
    'ft': from_to(0.3048, 3.2_8084),
    'yd': from_to(0.9144, 1.0_9361),
    'mi': from_to(1609.34, 0.0_0062_1371),
}

def    _UpperCamelCase      (				SCREAMING_SNAKE_CASE__			:      float       ,						SCREAMING_SNAKE_CASE__			:      str       ,						SCREAMING_SNAKE_CASE__			:      str       ):
 '''simple docstring'''





 UpperCAmelCase__										=    from_type.lower().rstrip("""s"""       )
 UpperCAmelCase__										=    TYPE_CONVERSION.get(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
 UpperCAmelCase__										=    to_type.lower().rstrip("""s"""       )
 UpperCAmelCase__										=    TYPE_CONVERSION.get(SCREAMING_SNAKE_CASE__       ,						SCREAMING_SNAKE_CASE__       )
 if new_from not in METRIC_CONVERSION:
  UpperCAmelCase__										=    (
      F'''Invalid \'from_type\' value: {from_type!r}.\n'''
      F'''Conversion abbreviations are: {', '.join(SCREAMING_SNAKE_CASE__       )}'''
  )
  raise ValueError(SCREAMING_SNAKE_CASE__       )
 if new_to not in METRIC_CONVERSION:
  UpperCAmelCase__										=    (
      F'''Invalid \'to_type\' value: {to_type!r}.\n'''
      F'''Conversion abbreviations are: {', '.join(SCREAMING_SNAKE_CASE__       )}'''
  )
  raise ValueError(SCREAMING_SNAKE_CASE__       )
 return value * METRIC_CONVERSION[new_from].from_ * METRIC_CONVERSION[new_to].to


if __name__ == "__main__":
    import doctest

    doctest.testmod()
