


"""simple docstring"""


from __future__ import annotations

from collections.abc import Callable
from typing import Any, Generic, TypeVar

A  :     List[str]    					=    TypeVar("T")
class 						_UpperCamelCase						(     Generic[T]	):
							'''simple docstring'''







							def __init__(  self					,     __a					,     __a			):
										__lowerCAmelCase       					=    None

										__lowerCAmelCase       					=    len(lowercase__			)
										__lowerCAmelCase       					=    [any_type for _ in range(self.N			)] + arr
										__lowerCAmelCase       					=    fnc
										self.build()

							def     snake_case       (  self			):





										for p in range(self.N - 1					,     0					,     -1			):
													__lowerCAmelCase       					=    self.fn(self.st[p * 2]					,     self.st[p * 2 + 1]			)

							def     snake_case       (  self					,     __a					,     __a			):
										p += self.N
										__lowerCAmelCase       					=    v
										while p > 1:
													__lowerCAmelCase       					=    p // 2
													__lowerCAmelCase       					=    self.fn(self.st[p * 2]					,     self.st[p * 2 + 1]			)



							def     snake_case       (  self					,     __a					,     __a			):  # noqa: E741
										__lowerCAmelCase       					=    l + self.N, r + self.N

										__lowerCAmelCase       					=    None
										while l <= r:
													if l % 2 == 1:
																__lowerCAmelCase       					=    self.st[l] if res is None else self.fn(lowercase__					,     self.st[l]			)
													if r % 2 == 0:
																__lowerCAmelCase       					=    self.st[r] if res is None else self.fn(lowercase__					,     self.st[r]			)
													__lowerCAmelCase       					=    (l + 1) // 2, (r - 1) // 2
										return res


if __name__ == "__main__":
	from functools import reduce

	A  :     Any    					=    [1, 1_0, -2, 9, -3, 8, 4, -7, 5, 6, 1_1, -1_2]

	A  :     Union[str, Any]    					=    {
	    0: 7,
	    1: 2,
	    2: 6,
	    3: -1_4,
	    4: 5,
	    5: 4,
	    6: 7,
	    7: -1_0,
	    8: 9,
	    9: 1_0,
	    1_0: 1_2,
	    1_1: 1,
	}

	A  :     Optional[int]    					=    SegmentTree(test_array, min)
	A  :     Dict    					=    SegmentTree(test_array, max)
	A  :     Tuple    					=    SegmentTree(test_array, lambda a, b: a + b)


	def _lowerCamelCase			(	):

				'''simple docstring'''




				for i in range(len(lowerCAmelCase_   )   ):
							for j in range(lowerCAmelCase_					,				len(lowerCAmelCase_   )   ):
										__lowerCAmelCase       					=    reduce(lowerCAmelCase_					,				test_array[i : j + 1]   )
										__lowerCAmelCase       					=    reduce(lowerCAmelCase_					,				test_array[i : j + 1]   )
										__lowerCAmelCase       					=    reduce(lambda _UpperCamelCase					,				_UpperCamelCase   : a + b					,				test_array[i : j + 1]   )
										assert min_range == min_segment_tree.query(lowerCAmelCase_					,				lowerCAmelCase_   )
										assert max_range == max_segment_tree.query(lowerCAmelCase_					,				lowerCAmelCase_   )
										assert sum_range == sum_segment_tree.query(lowerCAmelCase_					,				lowerCAmelCase_   )

	test_all_segments()

	for index, value in test_updates.items():
		A  :     Tuple    					=    value
		min_segment_tree.update(index, value)
		max_segment_tree.update(index, value)
		sum_segment_tree.update(index, value)
		test_all_segments()









"""simple docstring"""


import cmath
import math


def _lowerCamelCase			(	_UpperCamelCase					,				_UpperCamelCase					,				_UpperCamelCase					,				_UpperCamelCase   ):

			'''simple docstring'''




			__lowerCAmelCase       					=    math.radians(_UpperCamelCase   )
			__lowerCAmelCase       					=    math.radians(_UpperCamelCase   )

			# Convert voltage and current to rectangular form
			__lowerCAmelCase       					=    cmath.rect(_UpperCamelCase					,				_UpperCamelCase   )
			__lowerCAmelCase       					=    cmath.rect(_UpperCamelCase					,				_UpperCamelCase   )

			# Calculate apparent power
			return voltage_rect * current_rect


if __name__ == "__main__":
	import doctest

	doctest.testmod()




