"""simple docstring"""



from collections.abc import Sequence
from queue import Queue






class       snake_case__	:


 def __init__(      self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase=None  ,						lowerCamelCase=None		):
        __a	      =  start
        __a	      =  end
        __a	      =  val
        __a	      =  (start + end) // 2
        __a	      =  left
        __a	      =  right






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






class       snake_case__	:


 def __init__(      self  ,						lowerCamelCase  ,						lowerCamelCase		):
        __a	      =  collection
        __a	      =  function
        if self.collection:
               __a	      =  self._build_tree(0  ,						len(_UpperCamelCase		) - 1		)


 def 		a__					(      self  ,						lowerCamelCase  ,						lowerCamelCase		):
        self._update_tree(self.root  ,						_UpperCamelCase  ,						_UpperCamelCase		)


 def 		a__					(      self  ,						lowerCamelCase  ,						lowerCamelCase		):
        return self._query_range(self.root  ,						_UpperCamelCase  ,						_UpperCamelCase		)


 def 		a__					(      self  ,						lowerCamelCase  ,						lowerCamelCase		):
        if start == end:
               return SegmentTreeNode(_UpperCamelCase  ,						_UpperCamelCase  ,						self.collection[start]		)
        __a	      =  (start + end) // 2
        __a	      =  self._build_tree(_UpperCamelCase  ,						_UpperCamelCase		)
        __a	      =  self._build_tree(mid + 1  ,						_UpperCamelCase		)
        return SegmentTreeNode(_UpperCamelCase  ,						_UpperCamelCase  ,						self.fn(left.val  ,						right.val		)  ,						_UpperCamelCase  ,						_UpperCamelCase		)


 def 		a__					(      self  ,						lowerCamelCase  ,						lowerCamelCase  ,						lowerCamelCase		):
        if node.start == i and node.end == i:
               __a	      =  val
               return
        if i <= node.mid:
               self._update_tree(node.left  ,						_UpperCamelCase  ,						_UpperCamelCase		)
        else:
               self._update_tree(node.right  ,						_UpperCamelCase  ,						_UpperCamelCase		)
        __a	      =  self.fn(node.left.val  ,						node.right.val		)


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






 def 		a__					(      self		):
        if self.root is not None:
               __a	      =  Queue()
               queue.put(self.root		)
               while not queue.empty():
                      __a	      =  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__:Tuple		       =       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()







import requests

snake_case__					:							int													=     'https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey='



def _a				(	lowerCamelCase:   str )	->						None:







      '''simple docstring'''






      __A          =				requests.get(_NEWS_API + bbc_news_api_key ).json()
      # each article in the list is a dict
      for i, article in enumerate(bbc_news_page['''articles''']					,				1 ):
            print(F"""{i}.) {article['title']}""" )


if __name__ == "__main__":
       fetch_bbc_news(bbc_news_api_key='<Your BBC News API key goes here>')





