

from collections.abc import Sequence
from queue import Queue







class 				lowercase       :




				def __init__(      self   ,     snake_case   ,     snake_case   ,     snake_case   ,     snake_case=None   ,     snake_case=None ):
											snake_case_           =					start
											snake_case_           =					end
											snake_case_           =					val
											snake_case_           =					(start + end) // 2
											snake_case_           =					left
											snake_case_           =					right




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







class 				lowercase       :




				def __init__(      self   ,     snake_case   ,     snake_case ):
											snake_case_           =					collection
											snake_case_           =					function
											if self.collection:
																		snake_case_           =					self._build_tree(0   ,     len(snake_case ) - 1 )




				def 					a							(      self   ,     snake_case   ,     snake_case ):
											self._update_tree(self.root   ,     snake_case   ,     snake_case )




				def 					a							(      self   ,     snake_case   ,     snake_case ):
											return self._query_range(self.root   ,     snake_case   ,     snake_case )




				def 					a							(      self   ,     snake_case   ,     snake_case ):
											if start == end:
																		return SegmentTreeNode(snake_case   ,     snake_case   ,     self.collection[start] )
											snake_case_           =					(start + end) // 2
											snake_case_           =					self._build_tree(snake_case   ,     snake_case )
											snake_case_           =					self._build_tree(mid + 1   ,     snake_case )
											return SegmentTreeNode(snake_case   ,     snake_case   ,     self.fn(left.val   ,     right.val )   ,     snake_case   ,     snake_case )




				def 					a							(      self   ,     snake_case   ,     snake_case   ,     snake_case ):
											if node.start == i and node.end == i:
																		snake_case_           =					val
																		return
											if i <= node.mid:
																		self._update_tree(node.left   ,     snake_case   ,     snake_case )
											else:
																		self._update_tree(node.right   ,     snake_case   ,     snake_case )
											snake_case_           =					self.fn(node.left.val   ,     node.right.val )




				def 					a							(      self   ,     snake_case   ,     snake_case   ,     snake_case ):
											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   ,     snake_case   ,     snake_case )
																		else:
																									# range in left child tree and right child tree
																									return self.fn(
																									    self._query_range(node.left   ,     snake_case   ,     node.mid )   ,     self._query_range(node.right   ,     node.mid + 1   ,     snake_case )   ,     )
											else:
																		# range in right child tree
																		return self._query_range(node.right   ,     snake_case   ,     snake_case )




				def 					a							(      self ):
											if self.root is not None:
																		snake_case_           =					Queue()
																		queue.put(self.root )
																		while not queue.empty():
																									snake_case_           =					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	:     Union[str, Any]		       = 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()







_UpperCAmelCase	:     str		       = [0, 2, 4, 6, 8]
_UpperCAmelCase	:     Any		       = [1, 3, 5, 7, 9]





def       __lowerCamelCase			(				UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							UpperCamelCase__   ):







							'''simple docstring'''






							if remaining_length == 0:
														if digits[0] == 0 or digits[-1] == 0:
																					return 0

														for i in range(length // 2 - 1     ,							-1     ,							-1   ):
																					remainder += digits[i] + digits[length - i - 1]

																					if remainder % 2 == 0:
																												return 0

																					remainder //= 10

														return 1

							if remaining_length == 1:
														if remainder % 2 == 0:
																					return 0

														snake_case_           =					0
														for digit in range(10   ):
																					snake_case_           =					digit
																					result += reversible_numbers(
																					    0     ,							(remainder + 2 * digit) // 10     ,							UpperCamelCase__     ,							UpperCamelCase__   )
														return result

							snake_case_           =					0
							for digita in range(10   ):
														snake_case_           =					digita

														if (remainder + digita) % 2 == 0:
																					snake_case_           =					ODD_DIGITS
														else:
																					snake_case_           =					EVEN_DIGITS

														for digita in other_parity_digits:
																					snake_case_           =					digita
																					result += reversible_numbers(
																					    remaining_length - 2     ,							(remainder + digita + digita) // 10     ,							UpperCamelCase__     ,							UpperCamelCase__     ,							)
							return result





def       __lowerCamelCase			(				UpperCamelCase__ = 9   ):







							'''simple docstring'''






							snake_case_           =					0
							for length in range(1     ,							max_power + 1   ):
														result += reversible_numbers(UpperCamelCase__     ,							0     ,							[0] * length     ,							UpperCamelCase__   )
							return result


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




