






import math
from itertools import permutations




def   lowercase__   (  __snake_case					:							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(__snake_case						) + 1						)  , 6						):
										if number % i == 0 or number % (i + 2) == 0:
															return False
					return True




def   lowercase__   (  __snake_case					:							int  , __snake_case					:							list						):


					'''simple docstring'''


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

					return False




def   lowercase__   (  ):


					'''simple docstring'''


					UpperCAmelCase_					:   Optional[int]   =		[n for n in range(1_001  , 10_000  , 2						) if is_prime(__snake_case						)]
					UpperCAmelCase_					:   Tuple   =		[]

					for number in prime_list:
										UpperCAmelCase_					:   Optional[Any]   =		[]

										for prime_member in permutations(list(str(__snake_case						)						)						):
															UpperCAmelCase_					:   Dict   =		int(''.join(__snake_case						)						)

															if prime % 2 == 0:
																				continue

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

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

					UpperCAmelCase_					:   Optional[Any]   =		[]
					for candidate in candidates:
										UpperCAmelCase_					:   Optional[Any]   =		len(__snake_case						)
										UpperCAmelCase_					:   List[Any]   =		False

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

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

					UpperCAmelCase_					:   str   =		set()
					for seq in passed:
										answer.add(''.join([str(__snake_case						) for i in seq]						)						)

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


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














from __future__ import annotations



class 						lowerCamelCase   :







		'''simple docstring'''



		def __init__(							self       ,	_UpperCamelCase = 0     )			->							None:
							UpperCAmelCase_					:   int   =		value
							UpperCAmelCase_					:   Node | None   =		None
							UpperCAmelCase_					:   Node | None   =		None





def   lowercase__   (  __snake_case					:							Node | None  , __snake_case					:							Node | None						):


					'''simple docstring'''


					if treea is None:
										return treea
					if treea is None:
										return treea

					UpperCAmelCase_					:   List[Any]   =		treea.value + treea.value
					UpperCAmelCase_					:   Dict   =		merge_two_binary_trees(treea.left  , treea.left						)
					UpperCAmelCase_					:   str   =		merge_two_binary_trees(treea.right  , treea.right						)
					return treea




def   lowercase__   (  __snake_case					:							Node | None						):


					'''simple docstring'''


					if root:
										print(root.value						)
										print_preorder(root.left						)
										print_preorder(root.right						)


if __name__ == "__main__":
		__UpperCAmelCase										=		Node(1)
		__UpperCAmelCase										=		Node(2)
		__UpperCAmelCase										=		Node(3)
		__UpperCAmelCase										=		Node(4)

		__UpperCAmelCase										=		Node(2)
		__UpperCAmelCase										=		Node(4)
		__UpperCAmelCase										=		Node(6)
		__UpperCAmelCase										=		Node(9)
		__UpperCAmelCase										=		Node(5)

		print('Tree1 is: ')
		print_preorder(treea)
		print('Tree2 is: ')
		print_preorder(treea)
		__UpperCAmelCase										=		merge_two_binary_trees(treea, treea)
		print('Merged Tree is: ')
		print_preorder(merged_tree)






