





from __future__ import annotations

from dataclasses import dataclass





@dataclass
class 						_A:


				"""simple docstring"""


				UpperCamelCase    :  Dict					    =	42
				UpperCamelCase    :  Any					    =	None
				UpperCamelCase    :  Union[str, Any]					    =	None







def  _SCREAMING_SNAKE_CASE				(   a  )      ->      bool:






					def is_valid_tree(a  ) -> bool:
										if node is None:
															return True

										if not isinstance(a					,						a  ):
															return False

										try:
															float(node.data  )
										except (TypeError, ValueError):
															return False

										return is_valid_tree(node.left  ) and is_valid_tree(node.right  )

					if not is_valid_tree(a  ):
										raise ValueError(
										    'Each node should be type of TreeNode and data should be float.'  )

					def is_binary_search_tree_recursive_check(
					    a					,						a					,						a  ) -> bool:

										if node is None:
															return True

										return (
										    left_bound < node.data < right_bound
										    and is_binary_search_tree_recursive_check(node.left					,						a					,						node.data  )
										    and is_binary_search_tree_recursive_check(
										        node.right					,						node.data					,						a  )
										)

					return is_binary_search_tree_recursive_check(a					,						-float('inf'  )					,						float('inf'  )  )


if __name__ == "__main__":
				import doctest

				doctest.testmod()











def _a				(	lowerCamelCase:   dict )	->						bool:







      '''simple docstring'''






      __A          =				set()
      # To detect a back edge, keep track of vertices currently in the recursion stack
      __A          =				set()
      return any(
          node not in visited and depth_first_search(lowerCamelCase					,				lowerCamelCase					,				lowerCamelCase					,				lowerCamelCase )
          for node in graph )



def _a				(	lowerCamelCase:   dict					,				lowerCamelCase:   int					,				lowerCamelCase:   set					,				lowerCamelCase:   set )	->						bool:







      '''simple docstring'''






      visited.add(lowerCamelCase )
      rec_stk.add(lowerCamelCase )

      for node in graph[vertex]:
            if node not in visited:
                  if depth_first_search(lowerCamelCase					,				lowerCamelCase					,				lowerCamelCase					,				lowerCamelCase ):
                        return True
            elif node in rec_stk:
                  return True

    # The node needs to be removed from recursion stack before function ends
      rec_stk.remove(lowerCamelCase )
      return False


if __name__ == "__main__":
       from doctest import testmod

       testmod()





