
import math






class 							SCREAMING_SNAKE_CASE__     :

							"""simple docstring"""






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





													'''simple docstring'''






													__UpperCamelCase  	=      len(SCREAMING_SNAKE_CASE_      )
													__UpperCamelCase  	=      [0] * (
													    4 * self.N
													)  # approximate the overall size of segment tree with array N
													self.build(1  ,						0  ,						self.N - 1      )



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_      )-> List[Any]:





													'''simple docstring'''






													return idx * 2



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_      )-> Any:





													'''simple docstring'''






													return idx * 2 + 1



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )-> str:  # noqa: E741





													'''simple docstring'''






													if l == r:
																			__UpperCamelCase  	=      A[l]
													else:
																			__UpperCamelCase  	=      (l + r) // 2
																			self.build(self.left(SCREAMING_SNAKE_CASE_      )  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )
																			self.build(self.right(SCREAMING_SNAKE_CASE_      )  ,						mid + 1  ,						SCREAMING_SNAKE_CASE_      )
																			__UpperCamelCase  	=      max(self.st[self.left(SCREAMING_SNAKE_CASE_      )]  ,						self.st[self.right(SCREAMING_SNAKE_CASE_      )]      )



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )-> str:





													'''simple docstring'''






													return self.update_recursive(1  ,						0  ,						self.N - 1  ,						a - 1  ,						b - 1  ,						SCREAMING_SNAKE_CASE_      )



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )-> Any:  # noqa: E741





													'''simple docstring'''






													if r < a or l > b:
																			return True
													if l == r:
																			__UpperCamelCase  	=      val
																			return True
													__UpperCamelCase  	=      (l + r) // 2
													self.update_recursive(self.left(SCREAMING_SNAKE_CASE_      )  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )
													self.update_recursive(self.right(SCREAMING_SNAKE_CASE_      )  ,						mid + 1  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )
													__UpperCamelCase  	=      max(self.st[self.left(SCREAMING_SNAKE_CASE_      )]  ,						self.st[self.right(SCREAMING_SNAKE_CASE_      )]      )
													return True



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )-> Dict:





													'''simple docstring'''






													return self.query_recursive(1  ,						0  ,						self.N - 1  ,						a - 1  ,						b - 1      )



							def      A__		(	self  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )-> str:  # noqa: E741





													'''simple docstring'''






													if r < a or l > b:
																			return -math.inf
													if l >= a and r <= b:
																			return self.st[idx]
													__UpperCamelCase  	=      (l + r) // 2
													__UpperCamelCase  	=      self.query_recursive(self.left(SCREAMING_SNAKE_CASE_      )  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )
													__UpperCamelCase  	=      self.query_recursive(self.right(SCREAMING_SNAKE_CASE_      )  ,						mid + 1  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )
													return max(SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )



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





													'''simple docstring'''






													__UpperCamelCase  	=      []
													for i in range(1  ,						N + 1      ):
																			show_list += [self.query(SCREAMING_SNAKE_CASE_  ,						SCREAMING_SNAKE_CASE_      )]
													print(SCREAMING_SNAKE_CASE_      )


if __name__ == "__main__":
				lowercase__				:				str						=      [1, 2, -4, 7, 3, -5, 6, 1_1, -2_0, 9, 1_4, 1_5, 5, 2, -8]
				lowercase__				:				Optional[Any]						=      1_5
				lowercase__				:				Optional[int]						=      SegmentTree(A)
				print(segt.query(4, 6))
				print(segt.query(7, 1_1))
				print(segt.query(7, 1_2))
				segt.update(1, 3, 1_1_1)
				print(segt.query(1, 1_5))
				segt.update(7, 8, 2_3_5)
				segt.show_data()












"""simple docstring"""





from __future__ import annotations


class   _lowercase			:


      def __init__(     self					:						int				, a					:						int = 0    ):





            """simple docstring"""







            __snake_case   :     Optional[Any]	      =value
            __snake_case   :     Node | None	      =None
            __snake_case   :     Node | None	      =None



def      __lowercase       (     a			:					Node | None							,		a			:					Node | None			)       ->       Node | None:
      if treea is None:
            return treea
      if treea is None:
            return treea

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



def      __lowercase       (     a			:					Node | None			)       ->       None:
      if root:
            print(root.value			)
            print_preorder(root.left			)
            print_preorder(root.right			)


if __name__ == "__main__":
    UpperCamelCase_						:					List[str]      				=			Node(1)
    UpperCamelCase_						:					List[Any]      				=			Node(2)
    UpperCamelCase_						:					Optional[Any]      				=			Node(3)
    UpperCamelCase_						:					int      				=			Node(4)

    UpperCamelCase_						:					int      				=			Node(2)
    UpperCamelCase_						:					List[str]      				=			Node(4)
    UpperCamelCase_						:					Any      				=			Node(6)
    UpperCamelCase_						:					Union[str, Any]      				=			Node(9)
    UpperCamelCase_						:					Dict      				=			Node(5)

    print("""Tree1 is: """)
    print_preorder(treea)
    print("""Tree2 is: """)
    print_preorder(treea)
    UpperCamelCase_						:					Optional[Any]      				=			merge_two_binary_trees(treea, treea)
    print("""Merged Tree is: """)
    print_preorder(merged_tree)


