




"""simple docstring"""


from collections.abc import Sequence
from queue import Queue






class 					lowercase:







 '''simple docstring'''





 def __init__(				self:		Dict,      a_:		Dict,      a_:		Any,      a_:		int,      a_:		Optional[Any]=None,      a_:		int=None		):




   '''simple docstring'''



   _snake_case							:		List[str]								=  start
   _snake_case							:		Optional[Any]								=  end
   _snake_case							:		Union[str, Any]								=  val
   _snake_case							:		str								=  (start + end) // 2
   _snake_case							:		List[str]								=  left
   _snake_case							:		Optional[Any]								=  right


 def __repr__(				self:		int		):




   '''simple docstring'''



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







class 					lowercase:







 '''simple docstring'''





 def __init__(				self:		Union[str, Any],      a_:		Sequence,      a_:		Tuple		):




   '''simple docstring'''



   _snake_case							:		List[Any]								=  collection
   _snake_case							:		List[str]								=  function
   if self.collection:
     _snake_case							:		str								=  self._build_tree(0,      len(a_		) - 1		)


 def  UpperCamelCase_   (				self:		List[str],      a_:		Tuple,      a_:		List[str]		):




   '''simple docstring'''



   self._update_tree(self.root,      a_,      a_		)


 def  UpperCamelCase_   (				self:		Any,      a_:		List[Any],      a_:		Optional[Any]		):




   '''simple docstring'''



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


 def  UpperCamelCase_   (				self:		Optional[int],      a_:		List[str],      a_:		int		):




   '''simple docstring'''



   if start == end:
     return SegmentTreeNode(a_,      a_,      self.collection[start]		)
   _snake_case							:		Optional[Any]								=  (start + end) // 2
   _snake_case							:		List[str]								=  self._build_tree(a_,      a_		)
   _snake_case							:		List[Any]								=  self._build_tree(mid + 1,      a_		)
   return SegmentTreeNode(a_,      a_,      self.fn(left.val,      right.val		),      a_,      a_		)


 def  UpperCamelCase_   (				self:		Optional[int],      a_:		List[Any],      a_:		Tuple,      a_:		Dict		):




   '''simple docstring'''



   if node.start == i and node.end == i:
     _snake_case							:		Any								=  val
     return
   if i <= node.mid:
     self._update_tree(node.left,      a_,      a_		)
   else:
     self._update_tree(node.right,      a_,      a_		)
   _snake_case							:		List[Any]								=  self.fn(node.left.val,      node.right.val		)


 def  UpperCamelCase_   (				self:		List[str],      a_:		Any,      a_:		Any,      a_:		Dict		):




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


 def  UpperCamelCase_   (				self:		Tuple		):




   '''simple docstring'''



   if self.root is not None:
     _snake_case							:		List[str]								=  Queue()
     queue.put(self.root		)
     while not queue.empty():
       _snake_case							:		int								=  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)
          A_						=				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"""


from math import factorial

A_						=				{str(d): factorial(d) for d in range(10)}


def 					UpperCAmelCase__       (snake_case__							:					int    ):
  """simple docstring"""

  return sum(DIGIT_FACTORIAL[d] for d in str(snake_case__    )    )


def 					UpperCAmelCase__       ():
  """simple docstring"""

  _snake_case							:		List[str]								=  7 * factorial(9    ) + 1
  return sum(i for i in range(3		,   snake_case__    ) if sum_of_digit_factorial(snake_case__    ) == i    )


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


