

from __future__ import annotations

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

lowerCAmelCase     :   int						     =  TypeVar('T')
class  _A		(  Generic[T]):

  def __init__(				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        SCREAMING_SNAKE_CASE_				:  Any | T           =     None

        SCREAMING_SNAKE_CASE_				:  int           =     len(_SCREAMING_SNAKE_CASE					)
        SCREAMING_SNAKE_CASE_				:  list[T]           =     [any_type for _ in range(self.N					)] + arr
        SCREAMING_SNAKE_CASE_				:  Optional[int]           =     fnc
        self.build()

  def  UpperCAmelCase    (				self					):





        """simple docstring"""







        for p in range(self.N - 1 ,					0 ,					-1					):
              SCREAMING_SNAKE_CASE_				:  Dict           =     self.fn(self.st[p * 2] ,					self.st[p * 2 + 1]					)

  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					):





        """simple docstring"""







        p += self.N
        SCREAMING_SNAKE_CASE_				:  Any           =     v
        while p > 1:
              SCREAMING_SNAKE_CASE_				:  int           =     p // 2
              SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     self.fn(self.st[p * 2] ,					self.st[p * 2 + 1]					)



  def  UpperCAmelCase    (				self ,					_SCREAMING_SNAKE_CASE ,					_SCREAMING_SNAKE_CASE					):  # noqa: E741





        """simple docstring"""







        SCREAMING_SNAKE_CASE_       ,						SCREAMING_SNAKE_CASE_				:  List[Any]           =     l + self.N, r + self.N

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


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

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

    lowerCAmelCase     :   Dict						     =  {
        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     :   List[Any]						     =  SegmentTree(test_array, min)
    lowerCAmelCase     :   int						     =  SegmentTree(test_array, max)
    lowerCAmelCase     :   int						     =  SegmentTree(test_array, lambda a, b: a + b)

    def    A_  (							):

          """simple docstring"""



          for i in range(len(a  )  ):
                for j in range(a					,   len(a  )  ):
                      SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     reduce(a					,   test_array[i : j + 1]  )
                      SCREAMING_SNAKE_CASE_				:  Any           =     reduce(a					,   test_array[i : j + 1]  )
                      SCREAMING_SNAKE_CASE_				:  Any           =     reduce(lambda a					,   a  : a + b					,   test_array[i : j + 1]  )
                      assert min_range == min_segment_tree.query(a					,   a  )
                      assert max_range == max_segment_tree.query(a					,   a  )
                      assert sum_range == sum_segment_tree.query(a					,   a  )

    test_all_segments()

    for index, value in test_updates.items():
        lowerCAmelCase     :   Tuple						     =  value
        min_segment_tree.update(index, value)
        max_segment_tree.update(index, value)
        sum_segment_tree.update(index, value)
        test_all_segments()









lowerCAmelCase     :   Tuple						     =  {
    'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.',
    'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.',
    'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-',
    'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----',
    '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
    '8': '---..', '9': '----.', '0': '-----', '&': '.-...', '@': '.--.-.',
    ':': '---...', ',': '--..--', '.': '.-.-.-', '\'': '.----.', '"': '.-..-.',
    '?': '..--..', '/': '-..-.', '=': '-...-', '+': '.-.-.', '-': '-....-',
    '(': '-.--.', ')': '-.--.-', '!': '-.-.--', ' ': '/'
}  # Exclamation mark is not in ITU-R recommendation
# fmt: on
lowerCAmelCase     :   Optional[int]						     =  {value: key for key, value in MORSE_CODE_DICT.items()}

def    A_  (							a  ):

      """simple docstring"""



      return " ".join(MORSE_CODE_DICT[char] for char in message.upper()  )

def    A_  (							a  ):

      """simple docstring"""



      return "".join(REVERSE_DICT[char] for char in message.split()  )

def    A_  (							):

      """simple docstring"""



      SCREAMING_SNAKE_CASE_				:  Tuple           =     'Morse code here!'
      print(a  )
      SCREAMING_SNAKE_CASE_				:  Optional[Any]           =     encrypt(a  )
      print(a  )
      SCREAMING_SNAKE_CASE_				:  Union[str, Any]           =     decrypt(a  )
      print(a  )


if __name__ == "__main__":
    main()






