






"""simple docstring"""


import math




class 	__UpperCamelCase    :
					def __init__(       self       :  Any    ,   UpperCAmelCase       :  Dict      )  ->					str:
											lowerCAmelCase      :Tuple				  = len(UpperCAmelCase      )
											lowerCAmelCase      :List[str]				  = [0] * (
											    4 * self.N
											)  # approximate the overall size of segment tree with array N
											self.build(1    ,   0    ,   self.N - 1      )
					def 					UpperCAmelCase__   (       self       :  Dict    ,   UpperCAmelCase       :  int      )  ->					Dict:
											return idx * 2
					def 					UpperCAmelCase__   (       self       :  Any    ,   UpperCAmelCase       :  List[Any]      )  ->					Optional[Any]:
											return idx * 2 + 1
					def 					UpperCAmelCase__   (       self       :  Dict    ,   UpperCAmelCase       :  Tuple    ,   UpperCAmelCase       :  List[Any]    ,   UpperCAmelCase       :  Any      )  ->					Dict:  # noqa: E741
											if l == r:
																	lowerCAmelCase      :List[str]				  = A[l]
											else:
																	lowerCAmelCase      :Optional[Any]				  = (l + r) // 2
																	self.build(self.left(UpperCAmelCase      )    ,   UpperCAmelCase    ,   UpperCAmelCase      )
																	self.build(self.right(UpperCAmelCase      )    ,   mid + 1    ,   UpperCAmelCase      )
																	lowerCAmelCase      :List[Any]				  = max(self.st[self.left(UpperCAmelCase      )]    ,   self.st[self.right(UpperCAmelCase      )]      )
					def 					UpperCAmelCase__   (       self       :  Any    ,   UpperCAmelCase       :  Tuple    ,   UpperCAmelCase       :  str    ,   UpperCAmelCase       :  str      )  ->					Union[str, Any]:
											return self.update_recursive(1    ,   0    ,   self.N - 1    ,   a - 1    ,   b - 1    ,   UpperCAmelCase      )
					def 					UpperCAmelCase__   (       self       :  Dict    ,   UpperCAmelCase       :  Optional[Any]    ,   UpperCAmelCase       :  str    ,   UpperCAmelCase       :  List[str]    ,   UpperCAmelCase       :  Dict    ,   UpperCAmelCase       :  List[str]    ,   UpperCAmelCase       :  Any      )  ->					Dict:  # noqa: E741
											if r < a or l > b:
																	return True
											if l == r:
																	lowerCAmelCase      :Optional[int]				  = val
																	return True
											lowerCAmelCase      :Dict				  = (l + r) // 2
											self.update_recursive(self.left(UpperCAmelCase      )    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase      )
											self.update_recursive(self.right(UpperCAmelCase      )    ,   mid + 1    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase      )
											lowerCAmelCase      :Any				  = max(self.st[self.left(UpperCAmelCase      )]    ,   self.st[self.right(UpperCAmelCase      )]      )
											return True
					def 					UpperCAmelCase__   (       self       :  int    ,   UpperCAmelCase       :  Optional[Any]    ,   UpperCAmelCase       :  Any      )  ->					Tuple:
											return self.query_recursive(1    ,   0    ,   self.N - 1    ,   a - 1    ,   b - 1      )
					def 					UpperCAmelCase__   (       self       :  Optional[int]    ,   UpperCAmelCase       :  str    ,   UpperCAmelCase       :  str    ,   UpperCAmelCase       :  Optional[int]    ,   UpperCAmelCase       :  List[Any]    ,   UpperCAmelCase       :  Tuple      )  ->					Union[str, Any]:  # noqa: E741
											if r < a or l > b:
																	return -math.inf
											if l >= a and r <= b:
																	return self.st[idx]
											lowerCAmelCase      :int				  = (l + r) // 2
											lowerCAmelCase      :Dict				  = self.query_recursive(self.left(UpperCAmelCase      )    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase      )
											lowerCAmelCase      :Any				  = self.query_recursive(self.right(UpperCAmelCase      )    ,   mid + 1    ,   UpperCAmelCase    ,   UpperCAmelCase    ,   UpperCAmelCase      )
											return max(UpperCAmelCase    ,   UpperCAmelCase      )
					def 					UpperCAmelCase__   (       self       :  Optional[Any]      )  ->					Tuple:
											lowerCAmelCase      :Tuple				  = []
											for i in range(1    ,   N + 1      ):
																	show_list += [self.query(UpperCAmelCase    ,   UpperCAmelCase      )]
											print(UpperCAmelCase      )


if __name__ == "__main__":
		__SCREAMING_SNAKE_CASE      =      [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
		__SCREAMING_SNAKE_CASE      =      15
		__SCREAMING_SNAKE_CASE      =      SegmentTree(A)
		print(segt.query(4, 6))
		print(segt.query(7, 11))
		print(segt.query(7, 12))
		segt.update(1, 3, 1_11)
		print(segt.query(1, 15))
		segt.update(7, 8, 2_35)
		segt.show_data()







"""simple docstring"""


import safs




class 	__UpperCamelCase    (    safs.SaFileSystem	):
					pass