






from collections.abc import Sequence
from queue import Queue

class 				lowerCAmelCase_	:


				def __init__(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase=None ,						_lowerCAmelCase=None      ):
											_lowercase							:   Any 							=   start
											_lowercase							:   Dict 							=   end
											_lowercase							:   Any 							=   val
											_lowercase							:   str 							=   (start + end) // 2
											_lowercase							:   Union[str, Any] 							=   left
											_lowercase							:   Optional[int] 							=   right


				def __repr__(					self      ):
											return F"""SegmentTreeNode(start={self.start}, end={self.end}, val={self.val})"""




class 				lowerCAmelCase_	:


				def __init__(					self ,						_lowerCAmelCase ,						_lowerCAmelCase      ):
											_lowercase							:   int 							=   collection
											_lowercase							:   List[str] 							=   function
											if self.collection:
																		_lowercase							:   Union[str, Any] 							=   self._build_tree(0 ,						len(lowerCAmelCase__      ) - 1      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase      ):
											self._update_tree(self.root ,						lowerCAmelCase__ ,						lowerCAmelCase__      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase      ):
											return self._query_range(self.root ,						lowerCAmelCase__ ,						lowerCAmelCase__      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase      ):




											if start == end:
																		return SegmentTreeNode(lowerCAmelCase__ ,						lowerCAmelCase__ ,						self.collection[start]      )
											_lowercase							:   Dict 							=   (start + end) // 2
											_lowercase							:   List[Any] 							=   self._build_tree(lowerCAmelCase__ ,						lowerCAmelCase__      )
											_lowercase							:   Optional[Any] 							=   self._build_tree(mid + 1 ,						lowerCAmelCase__      )
											return SegmentTreeNode(lowerCAmelCase__ ,						lowerCAmelCase__ ,						self.fn(left.val ,						right.val      ) ,						lowerCAmelCase__ ,						lowerCAmelCase__      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase      ):




											if node.start == i and node.end == i:
																		_lowercase							:   List[str] 							=   val
																		return
											if i <= node.mid:
																		self._update_tree(node.left ,						lowerCAmelCase__ ,						lowerCAmelCase__      )
											else:
																		self._update_tree(node.right ,						lowerCAmelCase__ ,						lowerCAmelCase__      )
											_lowercase							:   Dict 							=   self.fn(node.left.val ,						node.right.val      )


				def 						__a					(					self ,						_lowerCAmelCase ,						_lowerCAmelCase ,						_lowerCAmelCase      ):




											if node.start == i and node.end == j:
																		return node.val

											if i <= node.mid:
																		if j <= node.mid:
																									# range in left child tree
																									return self._query_range(node.left ,						lowerCAmelCase__ ,						lowerCAmelCase__      )
																		else:
																									# range in left child tree and right child tree
																									return self.fn(
																									    self._query_range(node.left ,						lowerCAmelCase__ ,						node.mid      ) ,						self._query_range(node.right ,						node.mid + 1 ,						lowerCAmelCase__      ) ,						)
											else:
																		# range in right child tree
																		return self._query_range(node.right ,						lowerCAmelCase__ ,						lowerCAmelCase__      )


				def 						__a					(					self      ):




											if self.root is not None:
																		_lowercase							:   Union[str, Any] 							=   Queue()
																		queue.put(self.root      )
																		while not queue.empty():
																									_lowercase							:   List[str] 							=   queue.get()
																									yield node

																									if node.left is not None:
																																queue.put(node.left      )

																									if node.right is not None:
																																queue.put(node.right      )


if __name__ == "__main__":
							import operator

							for fn in [operator.add, max, min]:
														print("*" * 50)
														UpperCamelCase								=		SegmentTree([2, 1, 5, 3, 4], fn)
														for node in arr.traverse():
																					print(node)
														print()

														arr.update(1, 5)
														for node in arr.traverse():
																					print(node)
														print()

														print(arr.query_range(3, 4))  # 7
														print(arr.query_range(2, 2))  # 5
														print(arr.query_range(1, 3))  # 13
														print()








def 						a__			(				A__ = 5_0_0_0_0_0_0_0				):
			SCREAMING_SNAKE_CASE_		:     Union[str, Any]					=					set()
			SCREAMING_SNAKE_CASE_		:     Optional[int]					=					int((limit - 2_4) ** (1 / 2)				)

			SCREAMING_SNAKE_CASE_		:     Dict					=					set(range(3,      prime_square_limit + 1,      2				)				)
			primes.add(2				)
			for p in range(3,      prime_square_limit + 1,      2				):
						if p not in primes:
									continue
						primes.difference_update(set(range(p * p,      prime_square_limit + 1,      A__				)				)				)

			for primea in primes:
						SCREAMING_SNAKE_CASE_		:     int					=					primea * primea
						for primea in primes:
									SCREAMING_SNAKE_CASE_		:     Dict					=					primea * primea * primea
									if square + cube >= limit - 1_6:
												break
									for primea in primes:
												SCREAMING_SNAKE_CASE_		:     Optional[int]					=					primea * primea * primea * primea
												SCREAMING_SNAKE_CASE_		:     str					=					square + cube + tetr
												if total >= limit:
															break
												ret.add(A__				)

			return len(A__				)


if __name__ == "__main__":
				print(F"""{solution() = }""")





