"""simple docstring"""







from dataclasses import dataclass
from typing import List, Optional, Union

import numpy as np
import PIL
from PIL import Image

from ...utils import is_torch_available, is_transformers_available


if is_transformers_available() and is_torch_available():
						from .image_encoder import PaintByExampleImageEncoder
						from .pipeline_paint_by_example import PaintByExamplePipeline


"""simple docstring"""







from __future__ import annotations

from collections import Counter


def 					a__ (						UpperCAmelCase__    :     int     )->		list[int]:
						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						,     UpperCAmelCase__						,     2     ):
												if is_prime[i]:
																		primes.append(UpperCAmelCase__     )

						return primes


def 					a__ (						UpperCAmelCase__    :     int     )->		list[list[int]]:
						UpperCAmelCase__   		=						str(UpperCAmelCase__     )
						UpperCAmelCase__   		=						[]
						UpperCAmelCase__   		=						["""0""", """1""", """2""", """3""", """4""", """5""", """6""", """7""", """8""", """9"""]

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

						return replacements


def 					a__ (						UpperCAmelCase__    :     int = 8     )->		int:
						UpperCAmelCase__   		=						set()

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

						for prime in primes:
												if prime in numbers_checked:
																		continue

												UpperCAmelCase__   		=						digit_replacements(UpperCAmelCase__     )

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

																		if len(UpperCAmelCase__     ) != family_length:
																								continue

																		return min(UpperCAmelCase__     )

						return -1


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

