





import math
from itertools import permutations
def 			__UpperCamelCase				(			lowercase__	:       str		)	->      bool:
    '''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(lowercase__		) + 1		)		,    6		):
        if number % i == 0 or number % (i + 2) == 0:
            return False
    return True
def 			__UpperCamelCase				(			lowercase__	:       List[str]		,    lowercase__	:       Dict		)	->      bool:
    '''simple docstring'''





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

    return False
def 			__UpperCamelCase				(			)	->      Optional[Any]:
    '''simple docstring'''





    lowerCAmelCase_					:	Optional[Any]						=   [n for n in range(1001		,    10000		,    2		) if is_prime(lowercase__		)]
    lowerCAmelCase_					:	Dict						=   []

    for number in prime_list:
        lowerCAmelCase_					:	Tuple						=   []

        for prime_member in permutations(list(str(lowercase__		)		)		):
            lowerCAmelCase_					:	Any						=   int("""""".join(lowercase__		)		)

            if prime % 2 == 0:
                continue

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

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

    lowerCAmelCase_					:	Optional[Any]						=   []
    for candidate in candidates:
        lowerCAmelCase_					:	str						=   len(lowercase__		)
        lowerCAmelCase_					:	List[Any]						=   False

        for i in range(lowercase__		):
            for j in range(i + 1		,    lowercase__		):
                for k in range(j + 1		,    lowercase__		):
                    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]]		)		)
                        lowerCAmelCase_					:	Any						=   True

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

    lowerCAmelCase_					:	int						=   set()
    for seq in passed:
        answer.add("""""".join([str(lowercase__		) for i in seq]		)		)

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


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









from __future__ import annotations

import math
from itertools import permutations
def 			__UpperCamelCase				(			lowercase__	:       int		)	->      bool:
    '''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(lowercase__		) + 1		)		,    6		):
        if number % i == 0 or number % (i + 2) == 0:
            return False
    return True
def 			__UpperCamelCase				(			lowercase__	:       int = 7		)	->      int:
    '''simple docstring'''





    lowerCAmelCase_					:	str						=   """""".join(str(lowercase__		) for i in range(1		,    n + 1		)		)
    lowerCAmelCase_					:	Any						=   [int("""""".join(lowercase__		)		) for i in permutations(lowercase__		,    lowercase__		)]
    lowerCAmelCase_					:	List[Any]						=   [num for num in perm_list if is_prime(lowercase__		)]
    return max(lowercase__		) if pandigitals else 0


if __name__ == "__main__":
  print(f"""{solution() = }""")


