






'''simple docstring'''







from __future__ import annotations

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

_A			:    Any					  =TypeVar('''T''')

class _lowercase			(       Generic[T]	):




							def __init__(							self:       Optional[Any]    ,							UpperCamelCase__:       list[T]    ,							UpperCamelCase__:       Callable[[T, T], T]  ):
														lowerCamelCase__      :			Any | T 						= None

														lowerCamelCase__      :			int 						= len(UpperCamelCase__  )
														lowerCamelCase__      :			list[T] 						= [any_type for _ in range(self.N  )] + arr
														lowerCamelCase__      :			Any 						= fnc
														self.build()




							def 	lowerCamelCase_       (							self:       List[Any]  ):
														for p in range(self.N - 1    ,							0    ,							-1  ):
																					lowerCamelCase__      :			Union[str, Any] 						= self.fn(self.st[p * 2]    ,							self.st[p * 2 + 1]  )




							def 	lowerCamelCase_       (							self:       Union[str, Any]    ,							UpperCamelCase__:       int    ,							UpperCamelCase__:       T  ):
														p += self.N
														lowerCamelCase__      :			int 						= v
														while p > 1:
																					lowerCamelCase__      :			str 						= p // 2
																					lowerCamelCase__      :			Optional[Any] 						= self.fn(self.st[p * 2]    ,							self.st[p * 2 + 1]  )




							def 	lowerCamelCase_       (							self:       Dict    ,							UpperCamelCase__:       int    ,							UpperCamelCase__:       int  ):  # noqa: E741
														lowerCamelCase__						,	lowerCamelCase__      :			Dict 						= l + self.N, r + self.N

														lowerCamelCase__      :			T | None 						= None
														while l <= r:
																					if l % 2 == 1:
																												lowerCamelCase__      :			str 						= self.st[l] if res is None else self.fn(UpperCamelCase__    ,							self.st[l]  )
																					if r % 2 == 0:
																												lowerCamelCase__      :			List[Any] 						= self.st[r] if res is None else self.fn(UpperCamelCase__    ,							self.st[r]  )
																					lowerCamelCase__						,	lowerCamelCase__      :			int 						= (l + 1) // 2, (r - 1) // 2
														return res


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

			_A			:    Any					  =[1, 10, -2, 9, -3, 8, 4, -7, 5, 6, 11, -12]

			_A			:    Union[str, Any]					  ={
			    0: 7,
			    1: 2,
			    2: 6,
			    3: -14,
			    4: 5,
			    5: 4,
			    6: 7,
			    7: -10,
			    8: 9,
			    9: 10,
			    10: 12,
			    11: 1,
			}

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





			def 				SCREAMING_SNAKE_CASE_ ()   -> None:
										for i in range(len(UpperCamelCase   )   ):
																	for j in range(UpperCamelCase       ,    len(UpperCamelCase   )   ):
																								lowerCamelCase__      :			Optional[int] 						= reduce(UpperCamelCase       ,    test_array[i : j + 1]   )
																								lowerCamelCase__      :			Tuple 						= reduce(UpperCamelCase       ,    test_array[i : j + 1]   )
																								lowerCamelCase__      :			Optional[int] 						= reduce(lambda UpperCamelCase       ,    UpperCamelCase   : a + b       ,    test_array[i : j + 1]   )
																								assert min_range == min_segment_tree.query(UpperCamelCase       ,    UpperCamelCase   )
																								assert max_range == max_segment_tree.query(UpperCamelCase       ,    UpperCamelCase   )
																								assert sum_range == sum_segment_tree.query(UpperCamelCase       ,    UpperCamelCase   )

			test_all_segments()

			for index, value in test_updates.items():
						_A			:    Optional[Any]					  =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 sys
import turtle





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase   )   -> tuple[float, float]:
							return (pa[0] + pa[0]) / 2, (pa[1] + pa[1]) / 2





def 				SCREAMING_SNAKE_CASE_ (UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase       ,    UpperCamelCase       ,    )   -> None:
							my_pen.up()
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.down()
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )
							my_pen.goto(vertexa[0]       ,    vertexa[1]   )

							if depth == 0:
														return

							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )
							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )
							triangle(UpperCamelCase       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    get_mid(UpperCamelCase       ,    UpperCamelCase   )       ,    depth - 1   )


if __name__ == "__main__":
			if len(sys.argv) != 2:
						raise ValueError(
						    '''Correct format for using this script: '''
						    '''python fractals.py <int:depth_for_fractal>'''
						)
			_A			:    Any					  =turtle.Turtle()
			my_pen.ht()
			my_pen.speed(5)
			my_pen.pencolor('''red''')

			_A			:    Dict					  =[(-175, -125), (0, 175), (175, -125)]  # vertices of triangle
			triangle(vertices[0], vertices[1], vertices[2], int(sys.argv[1]))

