from __future__ import annotations

import math

class        UpperCamelCase						:





						def __init__(self			,     __UpperCamelCase						)				->				Any:
												UpperCamelCase_		:							List[str]  =		size
												# approximate the overall size of segment tree with given value
												UpperCamelCase_		:							Tuple  =		[0 for i in range(0			,     4 * size						)]
												# create array to store lazy update
												UpperCamelCase_		:							int  =		[0 for i in range(0			,     4 * size						)]
												UpperCamelCase_		:							Tuple  =		[0 for i in range(0			,     4 * size						)]  # flag for lazy update





						def        A_							(self			,     __UpperCamelCase						)				->				List[str]:
												return idx * 2





						def        A_							(self			,     __UpperCamelCase						)				->				Any:
												return idx * 2 + 1





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)				->				Optional[int]:

												if left_element == right_element:
																		UpperCamelCase_		:							Union[str, Any]  =		a[left_element - 1]
												else:
																		UpperCamelCase_		:							List[str]  =		(left_element + right_element) // 2
																		self.build(self.left(_lowerCamelCase						)			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase						)
																		self.build(self.right(_lowerCamelCase						)			,     mid + 1			,     _lowerCamelCase			,     _lowerCamelCase						)
																		UpperCamelCase_		:							int  =		max(
																		    self.segment_tree[self.left(_lowerCamelCase						)]			,     self.segment_tree[self.right(_lowerCamelCase						)]						)





						def        A_							(self			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase			,     __UpperCamelCase						)				->				int:

												if self.flag[idx] is True:
																		UpperCamelCase_		:							Union[str, Any]  =		self.lazy[idx]
																		UpperCamelCase_		:							Dict  =		False
																		if left_element != right_element:
																								UpperCamelCase_		:							Optional[Any]  =		self.lazy[idx]
																								UpperCamelCase_		:							Optional[int]  =		self.lazy[idx]
																								UpperCamelCase_		:							Tuple  =		True
																								UpperCamelCase_		:							str  =		True

												if right_element < a or left_element > b:
																		return True
												if left_element >= a and right_element <= b:
																		UpperCamelCase_		:							Union[str, Any]  =		val
																		if left_element != right_element:
																								UpperCamelCase_		:							Union[str, Any]  =		val
																								UpperCamelCase_		:							List[Any]  =		val
																								UpperCamelCase_		:							Union[str, Any]  =		True
																								UpperCamelCase_		:							List[Any]  =		True
																		return True
												UpperCamelCase_		:							Tuple  =		(left_element + right_element) // 2
												self.update(self.left(_lowerCamelCase						)			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase						)
												self.update(self.right(_lowerCamelCase						)			,     mid + 1			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase						)
												UpperCamelCase_		:							Dict  =		max(
												    self.segment_tree[self.left(_lowerCamelCase						)]			,     self.segment_tree[self.right(_lowerCamelCase						)]						)
												return True





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

												if self.flag[idx] is True:
																		UpperCamelCase_		:							List[Any]  =		self.lazy[idx]
																		UpperCamelCase_		:							Optional[Any]  =		False
																		if left_element != right_element:
																								UpperCamelCase_		:							Tuple  =		self.lazy[idx]
																								UpperCamelCase_		:							Union[str, Any]  =		self.lazy[idx]
																								UpperCamelCase_		:							List[str]  =		True
																								UpperCamelCase_		:							str  =		True
												if right_element < a or left_element > b:
																		return -math.inf
												if left_element >= a and right_element <= b:
																		return self.segment_tree[idx]
												UpperCamelCase_		:							Union[str, Any]  =		(left_element + right_element) // 2
												UpperCamelCase_		:							Tuple  =		self.query(self.left(_lowerCamelCase						)			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase						)
												UpperCamelCase_		:							List[Any]  =		self.query(self.right(_lowerCamelCase						)			,     mid + 1			,     _lowerCamelCase			,     _lowerCamelCase			,     _lowerCamelCase						)
												return max(_lowerCamelCase			,     _lowerCamelCase						)





						def __str__(self						)				->				Optional[int]:
												return str([self.query(1			,     1			,     self.size			,     _lowerCamelCase			,     _lowerCamelCase						) for i in range(1			,     self.size + 1						)]						)


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









"""simple docstring"""
import cmath
import math




def 					a__						(						lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase			,	lowerCAmelCase    )	-> complex:
      UpperCAmelCase__			:							str							=    math.radians(lowerCAmelCase    )
      UpperCAmelCase__			:							Optional[int]							=    math.radians(lowerCAmelCase    )

      # Convert voltage and current to rectangular form
      UpperCAmelCase__			:							Union[str, Any]							=    cmath.rect(lowerCAmelCase			,	lowerCAmelCase    )
      UpperCAmelCase__			:							List[str]							=    cmath.rect(lowerCAmelCase			,	lowerCAmelCase    )

      # Calculate apparent power
      return voltage_rect * current_rect


if __name__ == "__main__":
    import doctest

    doctest.testmod()

