
"""simple docstring"""




import math
from itertools import permutations



def 				a__			(					lowerCAmelCase						:							int		):






     '''simple docstring'''

     if 1 < number < 4:
          # 2 and 3 are primes
          return True
     elif number < 2 or number % 2 == 0 or number % 3 == 0:
          # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
          return False

     # All primes number are in format of 6k +/- 1
     for i in range(5							,     int(math.sqrt(lowerCAmelCase		) + 1		)							,     6		):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True



def 				a__			(					lowerCAmelCase						:							int							,     lowerCAmelCase						:							list		):






     '''simple docstring'''
     UpperCAmelCase__				,						UpperCAmelCase__				:			Union[str, Any]							=    0, len(lowerCAmelCase		) - 1
     while left <= right:
          UpperCAmelCase__				:			str							=    (left + right) // 2
          if prime_list[middle] == target:
               return True
          elif prime_list[middle] < target:
               UpperCAmelCase__				:			List[str]							=    middle + 1
          else:
               UpperCAmelCase__				:			Any							=    middle - 1

     return False



def 				a__			(					):






     '''simple docstring'''
     UpperCAmelCase__				:			List[Any]							=    [n for n in range(1001							,     1_0000							,     2		) if is_prime(lowerCAmelCase		)]
     UpperCAmelCase__				:			Union[str, Any]							=    []

     for number in prime_list:
          UpperCAmelCase__				:			Union[str, Any]							=    []

          for prime_member in permutations(list(str(lowerCAmelCase		)		)		):
               UpperCAmelCase__				:			str							=    int("".join(lowerCAmelCase		)		)

               if prime % 2 == 0:
                    continue

               if search(lowerCAmelCase							,     lowerCAmelCase		):
                    tmp_numbers.append(lowerCAmelCase		)

          tmp_numbers.sort()
          if len(lowerCAmelCase		) >= 3:
               candidates.append(lowerCAmelCase		)

     UpperCAmelCase__				:			str							=    []
     for candidate in candidates:
          UpperCAmelCase__				:			List[Any]							=    len(lowerCAmelCase		)
          UpperCAmelCase__				:			Dict							=    False

          for i in range(lowerCAmelCase		):
               for j in range(i + 1							,     lowerCAmelCase		):
                    for k in range(j + 1							,     lowerCAmelCase		):
                         if (
                             abs(candidate[i] - candidate[j]		)
                             == abs(candidate[j] - candidate[k]		)
                             and len({candidate[i], candidate[j], candidate[k]}		) == 3
                         ):
                              passed.append(
                                  sorted([candidate[i], candidate[j], candidate[k]]		)		)
                              UpperCAmelCase__				:			Union[str, Any]							=    True

                         if found:
                              break
                    if found:
                         break
               if found:
                    break

     UpperCAmelCase__				:			Optional[int]							=    set()
     for seq in passed:
          answer.add("".join([str(lowerCAmelCase		) for i in seq]		)		)

     return max(int(lowerCAmelCase		) for x in answer		)


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





"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


A__   :						Optional[Any] 							=     {"""configuration_vilt""": ["""VILT_PRETRAINED_CONFIG_ARCHIVE_MAP""", """ViltConfig"""]}

try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A__   :						List[Any] 							=     ["""ViltFeatureExtractor"""]
    A__   :						Any 							=     ["""ViltImageProcessor"""]
    A__   :						int 							=     ["""ViltProcessor"""]

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    A__   :						str 							=     [
        """VILT_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """ViltForImageAndTextRetrieval""",
        """ViltForImagesAndTextClassification""",
        """ViltForTokenClassification""",
        """ViltForMaskedLM""",
        """ViltForQuestionAnswering""",
        """ViltLayer""",
        """ViltModel""",
        """ViltPreTrainedModel""",
    ]


if TYPE_CHECKING:
    from .configuration_vilt import VILT_PRETRAINED_CONFIG_ARCHIVE_MAP, ViltConfig

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .feature_extraction_vilt import ViltFeatureExtractor
        from .image_processing_vilt import ViltImageProcessor
        from .processing_vilt import ViltProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_vilt import (
            VILT_PRETRAINED_MODEL_ARCHIVE_LIST,
            ViltForImageAndTextRetrieval,
            ViltForImagesAndTextClassification,
            ViltForMaskedLM,
            ViltForQuestionAnswering,
            ViltForTokenClassification,
            ViltLayer,
            ViltModel,
            ViltPreTrainedModel,
        )


else:
    import sys

    A__   :						Any 							=     _LazyModule(__name__, globals()["""__file__"""], _import_structure)



