
"""simple docstring"""




import math







class 	_lowercase    :


     '''simple docstring'''





     def __init__(   self			,      __UpperCamelCase	)->       str:
          UpperCAmelCase__				:			Tuple							=    len(__UpperCamelCase	)
          UpperCAmelCase__				:			int							=    [0] * (
              4 * self.N
          )  # approximate the overall size of segment tree with array N
          self.build(1			,      0			,      self.N - 1	)



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase	)->       Tuple:
          return idx * 2



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase	)->       List[Any]:
          return idx * 2 + 1



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)->       str:  # noqa: E741
          if l == r:
               UpperCAmelCase__				:			Dict							=    A[l]
          else:
               UpperCAmelCase__				:			List[Any]							=    (l + r) // 2
               self.build(self.left(__UpperCamelCase	)			,      __UpperCamelCase			,      __UpperCamelCase	)
               self.build(self.right(__UpperCamelCase	)			,      mid + 1			,      __UpperCamelCase	)
               UpperCAmelCase__				:			Optional[Any]							=    max(self.st[self.left(__UpperCamelCase	)]			,      self.st[self.right(__UpperCamelCase	)]	)



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)->       List[str]:
          return self.update_recursive(1			,      0			,      self.N - 1			,      a - 1			,      b - 1			,      __UpperCamelCase	)



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)->       Optional[Any]:  # noqa: E741
          if r < a or l > b:
               return True
          if l == r:
               UpperCAmelCase__				:			Tuple							=    val
               return True
          UpperCAmelCase__				:			int							=    (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	)
          UpperCAmelCase__				:			List[Any]							=    max(self.st[self.left(__UpperCamelCase	)]			,      self.st[self.right(__UpperCamelCase	)]	)
          return True



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase	)->       int:
          return self.query_recursive(1			,      0			,      self.N - 1			,      a - 1			,      b - 1	)



     def 			lowerCAmelCase__							(   self			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)->       str:  # noqa: E741
          if r < a or l > b:
               return -math.inf
          if l >= a and r <= b:
               return self.st[idx]
          UpperCAmelCase__				:			List[Any]							=    (l + r) // 2
          UpperCAmelCase__				:			Tuple							=    self.query_recursive(self.left(__UpperCamelCase	)			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)
          UpperCAmelCase__				:			Union[str, Any]							=    self.query_recursive(self.right(__UpperCamelCase	)			,      mid + 1			,      __UpperCamelCase			,      __UpperCamelCase			,      __UpperCamelCase	)
          return max(__UpperCamelCase			,      __UpperCamelCase	)



     def 			lowerCAmelCase__							(   self	)->       int:
          UpperCAmelCase__				:			Dict							=    []
          for i in range(1			,      N + 1	):
               show_list += [self.query(__UpperCamelCase			,      __UpperCamelCase	)]
          print(__UpperCamelCase	)


if __name__ == "__main__":
    A__   :						List[str] 							=     [1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
    A__   :						List[str] 							=     15
    A__   :						Union[str, Any] 							=     SegmentTree(A)
    print(segt.query(4, 6))
    print(segt.query(7, 11))
    print(segt.query(7, 12))
    segt.update(1, 3, 111)
    print(segt.query(1, 15))
    segt.update(7, 8, 235)
    segt.show_data()





"""simple docstring"""




def 				a__			(					lowerCAmelCase						:							str		):






     '''simple docstring'''
     UpperCAmelCase__				:			Optional[Any]							=    str(lowerCAmelCase		).strip()
     if not oct_string:
          raise ValueError("Empty string was passed to the function"		)
     UpperCAmelCase__				:			Tuple							=    oct_string[0] == "-"
     if is_negative:
          UpperCAmelCase__				:			List[Any]							=    oct_string[1:]
     if not oct_string.isdigit() or not all(0 <= int(lowerCAmelCase		) <= 7 for char in oct_string		):
          raise ValueError("Non-octal value was passed to the function"		)
     UpperCAmelCase__				:			Optional[int]							=    0
     for char in oct_string:
          UpperCAmelCase__				:			Tuple							=    8 * decimal_number + int(lowerCAmelCase		)
     if is_negative:
          UpperCAmelCase__				:			int							=    -decimal_number
     return decimal_number


if __name__ == "__main__":
    from doctest import testmod

    testmod()



