


from __future__ import annotations







class 						_snake_case    :




 def __init__(						self   ,    _lowerCamelCase       ):
       a		:Any									=			data
       a		:Node | None									=			None
       a		:Node | None									=			None







def 							__lowerCamelCase		(					UpperCAmelCase_		:						Node | None		):  # In Order traversal of the tree




      """simple docstring"""





      if tree:
            display(tree.left		)
            print(tree.data		)
            display(tree.right		)
def 							__lowerCamelCase		(					UpperCAmelCase_		:						Node | None		):




      """simple docstring"""





      return 1 + max(depth_of_tree(tree.left		)					,    depth_of_tree(tree.right		)		) if tree else 0
def 							__lowerCamelCase		(					UpperCAmelCase_		:						Node		):




      """simple docstring"""





      if not tree:
            return True
      if tree.left and tree.right:
            return is_full_binary_tree(tree.left		) and is_full_binary_tree(tree.right		)
      else:
            return not tree.left and not tree.right
def 							__lowerCamelCase		(					):  # Main function for testing.




      """simple docstring"""





      a		:str									=			Node(1		)
      a		:Any									=			Node(2		)
      a		:int									=			Node(3		)
      a		:Dict									=			Node(4		)
      a		:Any									=			Node(5		)
      a		:Optional[Any]									=			Node(6		)
      a		:Any									=			Node(7		)
      a		:List[str]									=			Node(8		)
      a		:List[str]									=			Node(9		)

      print(is_full_binary_tree(UpperCAmelCase_		)		)
      print(depth_of_tree(UpperCAmelCase_		)		)
      print('''Tree is: '''		)
      display(UpperCAmelCase_		)


if __name__ == "__main__":
     main()









snake_case							:       Any										=	{0: [2, 3], 1: [0], 2: [1], 3: [4], 4: []}

snake_case							:       Any										=	{0: [1, 2, 3], 1: [2], 2: [0], 3: [4], 4: [5], 5: [3]}
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Any									=			True
      a		:Any									=			[]

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

      order.append(UpperCAmelCase_		)

      return order
def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]					,    UpperCAmelCase_		:						int					,    UpperCAmelCase_		:						list[bool]		):




      """simple docstring"""





      a		:Optional[Any]									=			True
      a		:int									=			[vert]

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

      return component






def 							__lowerCamelCase		(					UpperCAmelCase_		:						dict[int, list[int]]		):




      """simple docstring"""





      a		:int									=			len(UpperCAmelCase_		) * [False]
      a		:dict[int, list[int]]									=			{vert: [] for vert in range(len(UpperCAmelCase_		)		)}

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

      a		:Optional[Any]									=			[]
      for i, was_visited in enumerate(UpperCAmelCase_		):
            if not was_visited:
                  order += topology_sort(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)

      a		:Tuple									=			[]
      a		:int									=			len(UpperCAmelCase_		) * [False]

      for i in range(len(UpperCAmelCase_		)		):
            a		:Union[str, Any]									=			order[len(UpperCAmelCase_		) - i - 1]
            if not visited[vert]:
                  a		:Union[str, Any]									=			find_components(UpperCAmelCase_					,    UpperCAmelCase_					,    UpperCAmelCase_		)
                  components_list.append(UpperCAmelCase_		)

      return components_list





