



from __future__ import annotations

import math



class 							lowerCAmelCase_						:
       def __init__(     self,     SCREAMING_SNAKE_CASE_			)	->						None:
          UpperCamelCase       :    str		      =      size
          # approximate the overall size of segment tree with given value
          UpperCamelCase       :    Dict		      =      [0 for i in range(0,     4 * size			)]
          # create array to store lazy update
          UpperCamelCase       :    Dict		      =      [0 for i in range(0,     4 * size			)]
          UpperCamelCase       :    List[str]		      =      [0 for i in range(0,     4 * size			)]  # flag for lazy update
       def    snake_case_			(     self,     SCREAMING_SNAKE_CASE_			)	->						int:
          return idx * 2
       def    snake_case_			(     self,     SCREAMING_SNAKE_CASE_			)	->						int:
          return idx * 2 + 1
       def    snake_case_			(     self,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)	->						None:
          if left_element == right_element:
             UpperCamelCase       :    Dict		      =      a[left_element - 1]
          else:
             UpperCamelCase       :    str		      =      (left_element + right_element) // 2
             self.build(self.left(SCREAMING_SNAKE_CASE_			),     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
             self.build(self.right(SCREAMING_SNAKE_CASE_			),     mid + 1,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
             UpperCamelCase       :    Any		      =      max(
                 self.segment_tree[self.left(SCREAMING_SNAKE_CASE_			)],     self.segment_tree[self.right(SCREAMING_SNAKE_CASE_			)]			)
       def    snake_case_			(     self,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)	->						bool:
          if self.flag[idx] is True:
             UpperCamelCase       :    Union[str, Any]		      =      self.lazy[idx]
             UpperCamelCase       :    str		      =      False
             if left_element != right_element:
                UpperCamelCase       :    int		      =      self.lazy[idx]
                UpperCamelCase       :    Tuple		      =      self.lazy[idx]
                UpperCamelCase       :    Optional[Any]		      =      True
                UpperCamelCase       :    Tuple		      =      True

          if right_element < a or left_element > b:
             return True
          if left_element >= a and right_element <= b:
             UpperCamelCase       :    List[str]		      =      val
             if left_element != right_element:
                UpperCamelCase       :    Optional[int]		      =      val
                UpperCamelCase       :    Union[str, Any]		      =      val
                UpperCamelCase       :    Optional[int]		      =      True
                UpperCamelCase       :    List[Any]		      =      True
             return True
          UpperCamelCase       :    Union[str, Any]		      =      (left_element + right_element) // 2
          self.update(self.left(SCREAMING_SNAKE_CASE_			),     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
          self.update(self.right(SCREAMING_SNAKE_CASE_			),     mid + 1,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    Union[str, Any]		      =      max(
              self.segment_tree[self.left(SCREAMING_SNAKE_CASE_			)],     self.segment_tree[self.right(SCREAMING_SNAKE_CASE_			)]			)
          return True
       def    snake_case_			(     self,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)	->						int | float:
          if self.flag[idx] is True:
             UpperCamelCase       :    str		      =      self.lazy[idx]
             UpperCamelCase       :    Union[str, Any]		      =      False
             if left_element != right_element:
                UpperCamelCase       :    Optional[Any]		      =      self.lazy[idx]
                UpperCamelCase       :    Optional[int]		      =      self.lazy[idx]
                UpperCamelCase       :    Union[str, Any]		      =      True
                UpperCamelCase       :    int		      =      True
          if right_element < a or left_element > b:
             return -math.inf
          if left_element >= a and right_element <= b:
             return self.segment_tree[idx]
          UpperCamelCase       :    Any		      =      (left_element + right_element) // 2
          UpperCamelCase       :    int		      =      self.query(self.left(SCREAMING_SNAKE_CASE_			),     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
          UpperCamelCase       :    Optional[int]		      =      self.query(self.right(SCREAMING_SNAKE_CASE_			),     mid + 1,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)
          return max(SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			)






       def __str__(     self			)	->						str:
          return str([self.query(1,     1,     self.size,     SCREAMING_SNAKE_CASE_,     SCREAMING_SNAKE_CASE_			) for i in range(1,     self.size + 1			)]			)


if __name__ == "__main__":
    __UpperCAmelCase			  =			[1, 2, -4, 7, 3, -5, 6, 11, -20, 9, 14, 15, 5, 2, -8]
    __UpperCAmelCase			  =			15
    __UpperCAmelCase			  =			SegmentTree(size)
    segt.build(1, 1, size, A)
    print(segt.query(1, 1, size, 4, 6))
    print(segt.query(1, 1, size, 7, 11))
    print(segt.query(1, 1, size, 7, 12))
    segt.update(1, 1, size, 1, 3, 111)
    print(segt.query(1, 1, size, 1, 15))
    segt.update(1, 1, size, 7, 8, 235)
    print(segt)










from __future__ import annotations

from fractions import Fraction
from math import gcd, sqrt





def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE				)							-> bool:




    """simple docstring"""




    _A     =							int(number**0.5				)
    return number == sq * sq





def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)							-> tuple[int, int]:




    """simple docstring"""




    _A     =							x_num * y_den * z_den + y_num * x_den * z_den + z_num * x_den * y_den
    _A     =							x_den * y_den * z_den
    _A     =							gcd(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
    top //= hcf
    bottom //= hcf
    return top, bottom





def 				__lowerCAmelCase(       _SCREAMING_SNAKE_CASE = 35				)							-> int:




    """simple docstring"""




    _A     =							set()
    _A     =							42
    _A     =							Fraction(0				)
    _A     =							42

    for x_num in range(1							,     order + 1				):
        for x_den in range(x_num + 1							,     order + 1				):
            for y_num in range(1							,     order + 1				):
                for y_den in range(y_num + 1							,     order + 1				):
                    # n=1
                    _A     =							x_num * y_den + x_den * y_num
                    _A     =							x_den * y_den
                    _A     =							gcd(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                    z_num //= hcf
                    z_den //= hcf
                    if 0 < z_num < z_den <= order:
                        _A     =							add_three(
                            _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                        unique_s.add(_SCREAMING_SNAKE_CASE				)

                    # n=2
                    _A     =							(
                        x_num * x_num * y_den * y_den + x_den * x_den * y_num * y_num
                    )
                    _A     =							x_den * x_den * y_den * y_den
                    if is_sq(_SCREAMING_SNAKE_CASE				) and is_sq(_SCREAMING_SNAKE_CASE				):
                        _A     =							int(sqrt(_SCREAMING_SNAKE_CASE				)				)
                        _A     =							int(sqrt(_SCREAMING_SNAKE_CASE				)				)
                        _A     =							gcd(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                        z_num //= hcf
                        z_den //= hcf
                        if 0 < z_num < z_den <= order:
                            _A     =							add_three(
                                _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                            unique_s.add(_SCREAMING_SNAKE_CASE				)

                    # n=-1
                    _A     =							x_num * y_num
                    _A     =							x_den * y_num + x_num * y_den
                    _A     =							gcd(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                    z_num //= hcf
                    z_den //= hcf
                    if 0 < z_num < z_den <= order:
                        _A     =							add_three(
                            _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                        unique_s.add(_SCREAMING_SNAKE_CASE				)

                    # n=2
                    _A     =							x_num * x_num * y_num * y_num
                    _A     =							(
                        x_den * x_den * y_num * y_num + x_num * x_num * y_den * y_den
                    )
                    if is_sq(_SCREAMING_SNAKE_CASE				) and is_sq(_SCREAMING_SNAKE_CASE				):
                        _A     =							int(sqrt(_SCREAMING_SNAKE_CASE				)				)
                        _A     =							int(sqrt(_SCREAMING_SNAKE_CASE				)				)
                        _A     =							gcd(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                        z_num //= hcf
                        z_den //= hcf
                        if 0 < z_num < z_den <= order:
                            _A     =							add_three(
                                _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)
                            unique_s.add(_SCREAMING_SNAKE_CASE				)

    for num, den in unique_s:
        total += Fraction(_SCREAMING_SNAKE_CASE							,     _SCREAMING_SNAKE_CASE				)

    return total.denominator + total.numerator


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





