

from __future__ import annotations

from random import random






class        A_		:
							def __init__(		self		:			Any   ,SCREAMING_SNAKE_CASE__		:			int | None = None):
								__lowerCamelCase				:				Union[str, Any]					       = value
								__lowerCamelCase				:				int					       = random()
								__lowerCamelCase				:				Node | None					       = None
								__lowerCamelCase				:				Node | None					       = None
							def __repr__(		self		:			List[Any]):
								from pprint import pformat

								if self.left is None and self.right is None:
									return F"'{self.value}: {self.prior:.5}'"
								else:
									return pformat(
									    {F"{self.value}: {self.prior:.5}": (self.left, self.right)}   ,indent=1)


							def __str__(		self		:			Union[str, Any]):
								__lowerCamelCase				:				Optional[int]					       = str(self.value) + ' '
								__lowerCamelCase				:				Optional[Any]					       = str(self.left or '')
								__lowerCamelCase				:				List[Any]					       = str(self.right or '')
								return value + left + right






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__	, lowerCamelCase__			)  ->     tuple[Node | None, Node | None]:
	if root is None:  # None tree is split into 2 Nones
		return None, None
	elif root.value is None:
		return None, None
	else:
		if value < root.value:
			__lowerCamelCase       , __lowerCamelCase				:				Union[str, Any]					       = split(root.left	, lowerCamelCase__			)
			return left, root
		else:
			__lowerCamelCase       , __lowerCamelCase				:				List[str]					       = split(root.right	, lowerCamelCase__			)
			return root, right






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__	, lowerCamelCase__			)  ->     Node | None:
	if (not left) or (not right):  # If one node is None, return the other
		return left or right
	elif left.prior < right.prior:
		__lowerCamelCase				:				Optional[Any]					       = merge(left.right	, lowerCamelCase__			)
		return left
	else:
		__lowerCamelCase				:				List[str]					       = merge(lowerCamelCase__	, right.left			)
		return right






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__	, lowerCamelCase__			)  ->     Node | None:
	__lowerCamelCase				:				List[Any]					       = Node(lowerCamelCase__			)
	__lowerCamelCase       , __lowerCamelCase				:				Optional[int]					       = split(lowerCamelCase__	, lowerCamelCase__			)
	return merge(merge(lowerCamelCase__	, lowerCamelCase__			)	, lowerCamelCase__			)






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__	, lowerCamelCase__			)  ->     Node | None:
	__lowerCamelCase       , __lowerCamelCase				:				List[str]					       = split(lowerCamelCase__	, value - 1			)
	__lowerCamelCase       , __lowerCamelCase				:				Any					       = split(lowerCamelCase__	, lowerCamelCase__			)
	return merge(lowerCamelCase__	, lowerCamelCase__			)






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__			)  ->     None:
	if not root:  # None
		return
	else:
		inorder(root.left			)
		print(root.value	, end=','			)
		inorder(root.right			)






def    SCREAMING_SNAKE_CASE__       (  lowerCamelCase__	, lowerCamelCase__			)  ->     Node | None:
	for arg in args.split():
		if arg[0] == "+":
			__lowerCamelCase				:				str					       = insert(lowerCamelCase__	, int(arg[1:]			)			)

		elif arg[0] == "-":
			__lowerCamelCase				:				List[Any]					       = erase(lowerCamelCase__	, int(arg[1:]			)			)

		else:
			print('Unknown command'			)

	return root






def    SCREAMING_SNAKE_CASE__       (  )  ->     None:
	__lowerCamelCase				:				int					       = None
	print(
	    'enter numbers to create a tree, + value to add value into treap, '
	    '- value to erase all nodes with value. \'q\' to quit. '			)

	__lowerCamelCase				:				Optional[int]					       = input()
	while args != "q":
		__lowerCamelCase				:				Optional[int]					       = interact_treap(lowerCamelCase__	, lowerCamelCase__			)
		print(lowerCamelCase__			)
		__lowerCamelCase				:				int					       = input()

	print('good by!'			)


if __name__ == "__main__":
					import doctest

					doctest.testmod()
					main()










"""simple docstring"""




def     a__ (				snake_case__				)						->					bool:
			lowerCamelCase			      =					(1 + 24 * n) ** 0.5
			return ((1 + root) / 6) % 1 == 0



def     a__ (				snake_case__ = 50_00				)						->					int:
			lowerCamelCase			      =					[(i * (3 * i - 1)) // 2 for i in range(1       , snake_case__				)]
			for i, pentagonal_i in enumerate(snake_case__				):
						for j in range(snake_case__       , len(snake_case__				)				):
									lowerCamelCase			      =					pentagonal_nums[j]
									lowerCamelCase			      =					pentagonal_i + pentagonal_j
									lowerCamelCase			      =					pentagonal_j - pentagonal_i
									if is_pentagonal(snake_case__				) and is_pentagonal(snake_case__				):
												return b

			return -1


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



