import math






class 		a__						:

					def __init__(   self				:	Any,_A				:	List[str]   ):







							"""simple docstring"""






							SCREAMING_SNAKE_CASE_  :		Optional[int]    				=   len(_A   )
							SCREAMING_SNAKE_CASE_  :		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				:	List[Any],_A				:	int   ):







							"""simple docstring"""






							return idx * 2

					def     __UpperCamelCase       (   self				:	Any,_A				:	List[str]   ):







							"""simple docstring"""






							return idx * 2 + 1

					def     __UpperCamelCase       (   self				:	Optional[int],_A				:	int,_A				:	Dict,_A				:	Dict   ):  # noqa: E741







							"""simple docstring"""






							if l == r:
									SCREAMING_SNAKE_CASE_  :		int    				=   A[l]
							else:
									SCREAMING_SNAKE_CASE_  :		Tuple    				=   (l + r) // 2
									self.build(self.left(_A   ),_A,_A   )
									self.build(self.right(_A   ),mid + 1,_A   )
									SCREAMING_SNAKE_CASE_  :		Union[str, Any]    				=   max(self.st[self.left(_A   )],self.st[self.right(_A   )]   )

					def     __UpperCamelCase       (   self				:	Optional[int],_A				:	str,_A				:	Any,_A				:	Any   ):







							"""simple docstring"""






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

					def     __UpperCamelCase       (   self				:	Dict,_A				:	int,_A				:	str,_A				:	int,_A				:	Any,_A				:	int,_A				:	Optional[Any]   ):  # noqa: E741







							"""simple docstring"""






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

					def     __UpperCamelCase       (   self				:	Tuple,_A				:	Tuple,_A				:	Optional[int]   ):







							"""simple docstring"""






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

					def     __UpperCamelCase       (   self				:	Any,_A				:	str,_A				:	str,_A				:	Optional[int],_A				:	Optional[int],_A				:	List[Any]   ):  # noqa: E741







							"""simple docstring"""






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






					def     __UpperCamelCase       (   self				:	Any   ):







							"""simple docstring"""






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


if __name__ == "__main__":
			__lowerCamelCase :     List[str]          =  [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
			__lowerCamelCase :     Union[str, Any]          =  15
			__lowerCamelCase :     List[Any]          =  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()

from ..utils import DummyObject, requires_backends






class 		a__						( metaclass=A__ ):
					A     	=							['tensorflow_text']

					def __init__(   self				:	List[str],*_A				:	Optional[Any],**_A				:	int   ):







							"""simple docstring"""






							requires_backends(self,["tensorflow_text"]   )
