from __future__ import annotations

import math
import random
from typing import Any

class 						A__							:




						def __init__(       self					:      List[str]  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =[]
										_SCREAMING_SNAKE_CASE			  =0
										_SCREAMING_SNAKE_CASE			  =0




						def 							__UpperCamelCase				(       self					:      Tuple  )							->     bool:


										"""simple docstring"""





										return self.head == self.tail




						def 							__UpperCamelCase				(       self					:      str				,    _a					:      Any  )							->     None:


										"""simple docstring"""





										self.data.append(_a  )
										_SCREAMING_SNAKE_CASE			  =self.tail + 1




						def 							__UpperCamelCase				(       self					:      Any  )							->     Any:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =self.data[self.head]
										_SCREAMING_SNAKE_CASE			  =self.head + 1
										return ret




						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     int:


										"""simple docstring"""





										return self.tail - self.head




						def 							__UpperCamelCase				(       self					:      List[Any]  )							->     None:


										"""simple docstring"""





										print(self.data  )
										print('''**************'''  )
										print(self.data[self.head : self.tail]  )

class 						A__							:




						def __init__(       self					:      Dict				,    _a					:      Any  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =data
										_SCREAMING_SNAKE_CASE			  =None
										_SCREAMING_SNAKE_CASE			  =None
										_SCREAMING_SNAKE_CASE			  =1




						def 							__UpperCamelCase				(       self					:      Dict  )							->     Any:


										"""simple docstring"""





										return self.data




						def 							__UpperCamelCase				(       self					:      int  )							->     MyNode | None:


										"""simple docstring"""





										return self.left




						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     MyNode | None:


										"""simple docstring"""





										return self.right




						def 							__UpperCamelCase				(       self					:      Union[str, Any]  )							->     int:


										"""simple docstring"""





										return self.height




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      Any  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =data




						def 							__UpperCamelCase				(       self					:      Optional[int]				,    _a					:      MyNode | None  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =node




						def 							__UpperCamelCase				(       self					:      Tuple				,    _a					:      MyNode | None  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =node




						def 							__UpperCamelCase				(       self					:      List[Any]				,    _a					:      int  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =height







def 						lowerCamelCase(   a__):
				if node is None:
								return 0
				return node.get_height()







def 						lowerCamelCase(   a__	,a__):
				if a > b:
								return a
				return b







def 						lowerCamelCase(   a__):
				print('''left rotation node:'''	,node.get_data())
				_SCREAMING_SNAKE_CASE			  =node.get_left()
				assert ret is not None
				node.set_left(ret.get_right())
				ret.set_right(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(node.get_right())	,get_height(node.get_left())) + 1
				node.set_height(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(ret.get_right())	,get_height(ret.get_left())) + 1
				ret.set_height(a__)
				return ret







def 						lowerCamelCase(   a__):
				print('''right rotation node:'''	,node.get_data())
				_SCREAMING_SNAKE_CASE			  =node.get_right()
				assert ret is not None
				node.set_right(ret.get_left())
				ret.set_left(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(node.get_right())	,get_height(node.get_left())) + 1
				node.set_height(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(ret.get_right())	,get_height(ret.get_left())) + 1
				ret.set_height(a__)
				return ret







def 						lowerCamelCase(   a__):
				_SCREAMING_SNAKE_CASE			  =node.get_left()
				assert left_child is not None
				node.set_left(left_rotation(a__))
				return right_rotation(a__)







def 						lowerCamelCase(   a__):
				_SCREAMING_SNAKE_CASE			  =node.get_right()
				assert right_child is not None
				node.set_right(right_rotation(a__))
				return left_rotation(a__)







def 						lowerCamelCase(   a__	,a__):
				if node is None:
								return MyNode(a__)
				if data < node.get_data():
								node.set_left(insert_node(node.get_left()	,a__))
								if (
								    get_height(node.get_left()) - get_height(node.get_right()) == 2
								):  # an unbalance detected
												_SCREAMING_SNAKE_CASE			  =node.get_left()
												assert left_child is not None
												if (
												    data < left_child.get_data()
												):  # new node is the left child of the left child
																_SCREAMING_SNAKE_CASE			  =right_rotation(a__)
												else:
																_SCREAMING_SNAKE_CASE			  =lr_rotation(a__)
				else:
								node.set_right(insert_node(node.get_right()	,a__))
								if get_height(node.get_right()) - get_height(node.get_left()) == 2:
												_SCREAMING_SNAKE_CASE			  =node.get_right()
												assert right_child is not None
												if data < right_child.get_data():
																_SCREAMING_SNAKE_CASE			  =rl_rotation(a__)
												else:
																_SCREAMING_SNAKE_CASE			  =left_rotation(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(node.get_right())	,get_height(node.get_left())) + 1
				node.set_height(a__)
				return node







def 						lowerCamelCase(   a__):
				while True:
								_SCREAMING_SNAKE_CASE			  =root.get_right()
								if right_child is None:
												break
								_SCREAMING_SNAKE_CASE			  =right_child
				return root.get_data()







def 						lowerCamelCase(   a__):
				while True:
								_SCREAMING_SNAKE_CASE			  =root.get_left()
								if left_child is None:
												break
								_SCREAMING_SNAKE_CASE			  =left_child
				return root.get_data()







def 						lowerCamelCase(   a__	,a__):
				_SCREAMING_SNAKE_CASE			  =root.get_left()
				_SCREAMING_SNAKE_CASE			  =root.get_right()
				if root.get_data() == data:
								if left_child is not None and right_child is not None:
												_SCREAMING_SNAKE_CASE			  =get_left_most(a__)
												root.set_data(a__)
												root.set_right(del_node(a__	,a__))
								elif left_child is not None:
												_SCREAMING_SNAKE_CASE			  =left_child
								elif right_child is not None:
												_SCREAMING_SNAKE_CASE			  =right_child
								else:
												return None
				elif root.get_data() > data:
								if left_child is None:
												print('''No such data''')
												return root
								else:
												root.set_left(del_node(a__	,a__))
				else:  # root.get_data() < data
								if right_child is None:
												return root
								else:
												root.set_right(del_node(a__	,a__))

				if get_height(a__) - get_height(a__) == 2:
								assert right_child is not None
								if get_height(right_child.get_right()) > get_height(right_child.get_left()):
												_SCREAMING_SNAKE_CASE			  =left_rotation(a__)
								else:
												_SCREAMING_SNAKE_CASE			  =rl_rotation(a__)
				elif get_height(a__) - get_height(a__) == -2:
								assert left_child is not None
								if get_height(left_child.get_left()) > get_height(left_child.get_right()):
												_SCREAMING_SNAKE_CASE			  =right_rotation(a__)
								else:
												_SCREAMING_SNAKE_CASE			  =lr_rotation(a__)
				_SCREAMING_SNAKE_CASE			  =my_max(get_height(root.get_right())	,get_height(root.get_left())) + 1
				root.set_height(a__)
				return root

class 						A__							:




						def __init__(       self					:      Tuple  )							->     None:


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =None




						def 							__UpperCamelCase				(       self					:      str  )							->     int:


										"""simple docstring"""





										return get_height(self.root  )




						def 							__UpperCamelCase				(       self					:      Dict				,    _a					:      Any  )							->     None:


										"""simple docstring"""





										print('''insert:''' + str(_a  )  )
										_SCREAMING_SNAKE_CASE			  =insert_node(self.root				,    _a  )




						def 							__UpperCamelCase				(       self					:      Optional[int]				,    _a					:      Any  )							->     None:


										"""simple docstring"""





										print('''delete:''' + str(_a  )  )
										if self.root is None:
														print('''Tree is empty!'''  )
														return
										_SCREAMING_SNAKE_CASE			  =del_node(self.root				,    _a  )




						def __str__(       self					:      Union[str, Any]				,    )							->     str:  # a level traversale, gives a more intuitive look on the tree


										"""simple docstring"""





										_SCREAMING_SNAKE_CASE			  =''''''
										_SCREAMING_SNAKE_CASE			  =MyQueue()
										q.push(self.root  )
										_SCREAMING_SNAKE_CASE			  =self.get_height()
										if layer == 0:
														return output
										_SCREAMING_SNAKE_CASE			  =0
										while not q.is_empty():
														_SCREAMING_SNAKE_CASE			  =q.pop()
														_SCREAMING_SNAKE_CASE			  =''' ''' * int(math.pow(2				,    layer - 1  )  )
														output += space
														if node is None:
																		output += "*"
																		q.push(_a  )
																		q.push(_a  )
														else:
																		output += str(node.get_data()  )
																		q.push(node.get_left()  )
																		q.push(node.get_right()  )
														output += space
														_SCREAMING_SNAKE_CASE			  =cnt + 1
														for i in range(100  ):
																		if cnt == math.pow(2				,    _a  ) - 1:
																						_SCREAMING_SNAKE_CASE			  =layer - 1
																						if layer == 0:
																										output += "\n*************************************"
																										return output
																						output += "\n"
																						break
										output += "\n*************************************"
										return output







def 						lowerCamelCase(   ):
				import doctest

				doctest.testmod()


if __name__ == "__main__":
							_test()
							snake_case_						:			Tuple													=							AVLtree()
							snake_case_						:			Any													=							list(range(10))
							random.shuffle(lst)
							for i in lst:
														t.insert(i)
														print(str(t))
							random.shuffle(lst)
							for i in lst:
														t.del_node(i)
														print(str(t))



snake_case_						:			dict[tuple[int, int, int], int]													=							{}







def 						lowerCamelCase(   a__	,a__	,a__):

				# if we are absent twice, or late 3 consecutive days,
				# no further prize strings are possible
				if late == 3 or absent == 2:
								return 0

				# if we have no days left, and have not failed any other rules,
				# we have a prize string
				if days == 0:
								return 1

				# No easy solution, so now we need to do the recursive calculation

				# First, check if the combination is already in the cache, and
				# if yes, return the stored value from there since we already
				# know the number of possible prize strings from this point on
				_SCREAMING_SNAKE_CASE			  =(days, absent, late)
				if key in cache:
								return cache[key]

				# now we calculate the three possible ways that can unfold from
				# this point on, depending on our attendance today

				# 1) if we are late (but not absent), the "absent" counter stays as
				# it is, but the "late" counter increases by one
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,a__	,late + 1)

				# 2) if we are absent, the "absent" counter increases by 1, and the
				# "late" counter resets to 0
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,absent + 1	,0)

				# 3) if we are on time, this resets the "late" counter and keeps the
				# absent counter
				_SCREAMING_SNAKE_CASE			  =_calculate(days - 1	,a__	,0)

				_SCREAMING_SNAKE_CASE			  =state_late + state_absent + state_ontime

				_SCREAMING_SNAKE_CASE			  =prizestrings
				return prizestrings







def 						lowerCamelCase(   a__ = 30):
				return _calculate(a__	,absent=0	,late=0)


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