

lowerCAmelCase							:  Union[str, Any]   	=						{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

lowerCAmelCase							:  List[Any]   	=						{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: List[str]  		=       True
						SCREAMING_SNAKE_CASE_: Optional[int]  		=       []

						for neighbour in graph[vert]:
												if not visited[neighbour]:
																		order += topology_sort(_UpperCamelCase				,	_UpperCamelCase				,	_UpperCamelCase    )

						order.append(_UpperCamelCase    )

						return order







def 			A_      (    _UpperCAmelCase				,	_UpperCAmelCase				,	_UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: str  		=       True
						SCREAMING_SNAKE_CASE_: Optional[Any]  		=       [vert]

						for neighbour in reversed_graph[vert]:
												if not visited[neighbour]:
																		component += find_components(_UpperCamelCase				,	_UpperCamelCase				,	_UpperCamelCase    )

						return component







def 			A_      (    _UpperCAmelCase    ):
						SCREAMING_SNAKE_CASE_: Tuple  		=       len(_UpperCamelCase    ) * [False]
						SCREAMING_SNAKE_CASE_: Tuple  		=       {vert: [] for vert in range(len(_UpperCamelCase    )    )}

						for vert, neighbours in graph.items():
												for neighbour in neighbours:
																		reversed_graph[neighbour].append(_UpperCamelCase    )

						SCREAMING_SNAKE_CASE_: int  		=       []
						for i, was_visited in enumerate(_UpperCamelCase    ):
												if not was_visited:
																		order += topology_sort(_UpperCamelCase				,	_UpperCamelCase				,	_UpperCamelCase    )

						SCREAMING_SNAKE_CASE_: Tuple  		=       []
						SCREAMING_SNAKE_CASE_: List[Any]  		=       len(_UpperCamelCase    ) * [False]

						for i in range(len(_UpperCamelCase    )    ):
												SCREAMING_SNAKE_CASE_: List[Any]  		=       order[len(_UpperCamelCase    ) - i - 1]
												if not visited[vert]:
																		SCREAMING_SNAKE_CASE_: Dict  		=       find_components(_UpperCamelCase				,	_UpperCamelCase				,	_UpperCamelCase    )
																		components_list.append(_UpperCamelCase    )

						return components_list









'''simple docstring'''
class 							A__    :





  def __init__(		self      :	Union[str, Any]							,					_a      :	int )	->    None:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =size
       _SCREAMING_SNAKE_CASE							    =[0] * size
       _SCREAMING_SNAKE_CASE							    =[0] * size





  @staticmethod
  def 						A  (		_a      :	int )	->    int:





       '''simple docstring'''






       return index | (index + 1)





  @staticmethod
  def 						A  (		_a      :	int )	->    int:





       '''simple docstring'''






       return (index & (index + 1)) - 1





  def 						A  (		self      :	Tuple							,					_a      :	int							,					_a      :	int )	->    None:





       '''simple docstring'''






       _SCREAMING_SNAKE_CASE							    =value
       while index < self.size:
            _SCREAMING_SNAKE_CASE							    =self.get_prev(_a ) + 1
            if current_left_border == index:
                 _SCREAMING_SNAKE_CASE							    =value
            else:
                 _SCREAMING_SNAKE_CASE							    =max(_a							,					_a							,					_a )
            _SCREAMING_SNAKE_CASE							    =self.get_next(_a )





  def 						A  (		self      :	int							,					_a      :	int							,					_a      :	int )	->    int:





       '''simple docstring'''






       right -= 1  # Because of right is exclusive
       _SCREAMING_SNAKE_CASE							    =0
       while left <= right:
            _SCREAMING_SNAKE_CASE							    =self.get_prev(_a )
            if left <= current_left:
                 _SCREAMING_SNAKE_CASE							    =max(_a							,					self.tree[right] )
                 _SCREAMING_SNAKE_CASE							    =current_left
            else:
                 _SCREAMING_SNAKE_CASE							    =max(_a							,					self.arr[right] )
                 right -= 1
       return result


if __name__ == "__main__":
     import doctest

     doctest.testmod()
