"""simple docstring"""
from collections.abc import Sequence
from queue import Queue



class   lowerCAmelCase_    :



				"""simple docstring"""

				def __init__(				self		,    lowerCAmelCase		,    lowerCAmelCase		,    lowerCAmelCase		,    lowerCAmelCase=None		,    lowerCAmelCase=None    ):






										"""simple docstring"""

										snake_case								=			start
										snake_case								=			end
										snake_case								=			val
										snake_case								=			(start + end) // 2
										snake_case								=			left
										snake_case								=			right

				def __repr__(				self    ):






										"""simple docstring"""

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





class   lowerCAmelCase_    :



				"""simple docstring"""

				def __init__(				self		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

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

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

										self._update_tree(self.root		,    lowerCAmelCase		,    lowerCAmelCase    )

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

										return self._query_range(self.root		,    lowerCAmelCase		,    lowerCAmelCase    )

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

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

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

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

				def 		snake_case (				self		,    lowerCAmelCase		,    lowerCAmelCase		,    lowerCAmelCase    ):






										"""simple docstring"""

										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 		snake_case (				self    ):






										"""simple docstring"""

										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)
										SCREAMING_SNAKE_CASE__      						=  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()





"""simple docstring"""
def    lowerCAmelCase__    (			_UpperCamelCase       :				int ,			_UpperCamelCase       :				int					)					->				int:





						"""simple docstring"""






						return int((input_a, input_a).count(0					) == 0					)





def    lowerCAmelCase__    (			)					->				None:





						"""simple docstring"""






						assert and_gate(0 ,			0					) == 0
						assert and_gate(0 ,			1					) == 0
						assert and_gate(1 ,			0					) == 0
						assert and_gate(1 ,			1					) == 1


if __name__ == "__main__":
					test_and_gate()
					print(and_gate(1, 0))
					print(and_gate(0, 0))
					print(and_gate(0, 1))
					print(and_gate(1, 1))


