




from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


snake_case__ :						Optional[Any]     =			{
    '''configuration_big_bird''': ['''BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''BigBirdConfig''', '''BigBirdOnnxConfig'''],
}

try:
   if not is_sentencepiece_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case__ :						int     =			['''BigBirdTokenizer''']

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case__ :						Optional[Any]     =			['''BigBirdTokenizerFast''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case__ :						Dict     =			[
       '''BIG_BIRD_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''BigBirdForCausalLM''',
       '''BigBirdForMaskedLM''',
       '''BigBirdForMultipleChoice''',
       '''BigBirdForPreTraining''',
       '''BigBirdForQuestionAnswering''',
       '''BigBirdForSequenceClassification''',
       '''BigBirdForTokenClassification''',
       '''BigBirdLayer''',
       '''BigBirdModel''',
       '''BigBirdPreTrainedModel''',
       '''load_tf_weights_in_big_bird''',
   ]

try:
   if not is_flax_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   snake_case__ :						Dict     =			[
       '''FlaxBigBirdForCausalLM''',
       '''FlaxBigBirdForMaskedLM''',
       '''FlaxBigBirdForMultipleChoice''',
       '''FlaxBigBirdForPreTraining''',
       '''FlaxBigBirdForQuestionAnswering''',
       '''FlaxBigBirdForSequenceClassification''',
       '''FlaxBigBirdForTokenClassification''',
       '''FlaxBigBirdModel''',
       '''FlaxBigBirdPreTrainedModel''',
   ]

if TYPE_CHECKING:
   from .configuration_big_bird import BIG_BIRD_PRETRAINED_CONFIG_ARCHIVE_MAP, BigBirdConfig, BigBirdOnnxConfig

   try:
      if not is_sentencepiece_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_big_bird import BigBirdTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_big_bird_fast import BigBirdTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_big_bird import (
          BIG_BIRD_PRETRAINED_MODEL_ARCHIVE_LIST,
          BigBirdForCausalLM,
          BigBirdForMaskedLM,
          BigBirdForMultipleChoice,
          BigBirdForPreTraining,
          BigBirdForQuestionAnswering,
          BigBirdForSequenceClassification,
          BigBirdForTokenClassification,
          BigBirdLayer,
          BigBirdModel,
          BigBirdPreTrainedModel,
          load_tf_weights_in_big_bird,
      )

   try:
      if not is_flax_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_flax_big_bird import (
          FlaxBigBirdForCausalLM,
          FlaxBigBirdForMaskedLM,
          FlaxBigBirdForMultipleChoice,
          FlaxBigBirdForPreTraining,
          FlaxBigBirdForQuestionAnswering,
          FlaxBigBirdForSequenceClassification,
          FlaxBigBirdForTokenClassification,
          FlaxBigBirdModel,
          FlaxBigBirdPreTrainedModel,
      )

else:
   import sys

   snake_case__ :						Tuple     =			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)










from __future__ import annotations

from collections import Counter


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

  return primes


def 						lowercase		(     _lowerCAmelCase      ):
  UpperCAmelCase__    						=   str(_lowerCAmelCase      )
  UpperCAmelCase__    						=   []
  UpperCAmelCase__    						=   ["""0""", """1""", """2""", """3""", """4""", """5""", """6""", """7""", """8""", """9"""]

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

  return replacements


def 						lowercase		(     _lowerCAmelCase = 8      ):
  UpperCAmelCase__    						=   set()

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

  for prime in primes:
    if prime in numbers_checked:
      continue

    UpperCAmelCase__    						=   digit_replacements(_lowerCAmelCase      )

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

      if len(_lowerCAmelCase      ) != family_length:
        continue

      return min(_lowerCAmelCase      )

  return -1


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




