


from __future__ import annotations

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

lowerCAmelCase__      		= TypeVar('T')







class      lowerCAmelCase__       (				Generic[T]):




     '''simple docstring'''


     def __init__(						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				None:
            _A      :       Any | T				    = None

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


     def  _lowerCamelCase (						self)			->				None:
            for p in range(self.N - 1 ,						0 ,						-1):
                   _A      :       int				    = self.fn(self.st[p * 2] ,						self.st[p * 2 + 1])


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				None:
            p += self.N
            _A      :       List[str]				    = v
            while p > 1:
                   _A      :       List[Any]				    = p // 2
                   _A      :       Optional[int]				    = self.fn(self.st[p * 2] ,						self.st[p * 2 + 1])


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				T | None:  # noqa: E741
            _A    ,			_A      :       Optional[Any]				    = l + self.N, r + self.N

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


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

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

    lowerCAmelCase__      		= {
        0: 7,
        1: 2,
        2: 6,
        3: -14,
        4: 5,
        5: 4,
        6: 7,
        7: -10,
        8: 9,
        9: 10,
        10: 12,
        11: 1,
    }

    lowerCAmelCase__      		= SegmentTree(test_array, min)
    lowerCAmelCase__      		= SegmentTree(test_array, max)
    lowerCAmelCase__      		= SegmentTree(test_array, lambda a, b: a + b)
    def 							_UpperCAmelCase				():
           for i in range(len(UpperCamelCase__						)						):
                  for j in range(UpperCamelCase__				,							len(UpperCamelCase__						)						):
                         _A      :       Any				    = reduce(UpperCamelCase__				,							test_array[i : j + 1]						)
                         _A      :       Optional[int]				    = reduce(UpperCamelCase__				,							test_array[i : j + 1]						)
                         _A      :       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():
        lowerCAmelCase__      		= 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 operator as op




def 							lowerCamelCase	(      UpperCAmelCase__       :					Optional[Any] )			->      int:
							lowercase_					:			Optional[Any]										=       []
							lowercase_					:			str										=       lambda UpperCAmelCase__      ,      UpperCAmelCase__ : int(x / y )  # noqa: E731 integer division operation
							lowercase_					:			Optional[Any]										=       {
							    """^""": op.pow,
							    """*""": op.mul,
							    """/""": div,
							    """+""": op.add,
							    """-""": op.sub,
							}  # operators & their respective operation

							# print table header
							print("""Symbol""".center(8 )      ,      """Action""".center(12 )      ,      """Stack"""      ,      sep=""" | """ )
							print("""-""" * (30 + len(UpperCAmelCase__ )) )

							for x in post_fix:
														if x.isdigit():  # if x in digit
																					stack.append(UpperCAmelCase__ )  # append x to stack
																					# output in tabular format
																					print(x.rjust(8 )      ,      ("""push(""" + x + """)""").ljust(12 )      ,      """,""".join(UpperCAmelCase__ )      ,      sep=""" | """ )
														else:
																					lowercase_					:			str										=       stack.pop()  # pop stack
																					# output in tabular format
																					print("""""".rjust(8 )      ,      ("""pop(""" + b + """)""").ljust(12 )      ,      """,""".join(UpperCAmelCase__ )      ,      sep=""" | """ )

																					lowercase_					:			Optional[int]										=       stack.pop()  # pop stack
																					# output in tabular format
																					print("""""".rjust(8 )      ,      ("""pop(""" + a + """)""").ljust(12 )      ,      """,""".join(UpperCAmelCase__ )      ,      sep=""" | """ )

																					stack.append(
																					    str(opr[x](int(UpperCAmelCase__ )      ,      int(UpperCAmelCase__ ) ) ) )  # evaluate the 2 values popped from stack & push result to stack
																					# output in tabular format
																					print(
																					    x.rjust(8 )      ,      ("""push(""" + a + x + b + """)""").ljust(12 )      ,      """,""".join(UpperCAmelCase__ )      ,      sep=""" | """      ,      )

							return int(stack[0] )


if __name__ == "__main__":
						_lowercase						: Tuple						=						input("\n\nEnter a Postfix Equation (space separated) = ").split(" ")
						print("\n\tResult = ", solve(Postfix))





