


'''simple docstring'''




def    UpperCAmelCase_  (       A      ):  # noqa: E741
   '''simple docstring'''





   _a					:  int						=  len(A      )
   _a					:  str						=  0
   _a					:  Optional[int]						=  [0] * n
   _a					:  int						=  [False] * n
   _a					:  List[str]						=  [False] * n

   def dfs(A		,	A		,	A		,	A      ):
      if parent == root:
         out_edge_count += 1
      _a					:  int						=  True
      _a					:  Any						=  at

      for to in l[at]:
         if to == parent:
            pass
         elif not visited[to]:
            _a					:  List[str]						=  dfs(A		,	A		,	A		,	A      )
            _a					:  Optional[int]						=  min(low[at]		,	low[to]      )

            # AP found via bridge
            if at < low[to]:
               _a					:  Optional[Any]						=  True
            # AP found via cycle
            if at == low[to]:
               _a					:  Optional[int]						=  True
         else:
            _a					:  Dict						=  min(low[at]		,	A      )
      return out_edge_count

   for i in range(A      ):
      if not visited[i]:
         _a					:  Union[str, Any]						=  0
         _a					:  Tuple						=  dfs(A		,	A		,	-1		,	A      )
         _a					:  Any						=  out_edge_count > 1

   for x in range(len(A      )      ):
      if is_art[x] is True:
         print(A      )


# Adjacency list of graph
UpperCAmelCase_      :		Dict          =		{
    0: [1, 2],
    1: [0, 2],
    2: [0, 1, 3, 5],
    3: [2, 4],
    4: [3],
    5: [2, 6, 8],
    6: [5, 7],
    7: [6, 8],
    8: [5, 7],
}







compute_ap(data)






'''simple docstring'''




from __future__ import annotations

from collections import namedtuple
from dataclasses import dataclass







@dataclass
class 					a			:
 '''simple docstring'''




 __lowerCAmelCase						: int
 __lowerCAmelCase						: TreeNode | None							  =		None
 __lowerCAmelCase						: TreeNode | None							  =		None





UpperCAmelCase_      :		Dict          =		namedtuple("CoinsDistribResult", "moves excess")


def    UpperCAmelCase_  (       A      ):
   '''simple docstring'''





   if root is None:
      return 0

   # Validation
   def count_nodes(A      ) -> int:
      if node is None:
         return 0

      return count_nodes(node.left      ) + count_nodes(node.right      ) + 1

   def count_coins(A      ) -> int:
      if node is None:
         return 0

      return count_coins(node.left      ) + count_coins(node.right      ) + node.data

   if count_nodes(A      ) != count_coins(A      ):
      raise ValueError('The nodes number should be same as the number of coins'      )

   # Main calculation
   def get_distrib(A      ) -> CoinsDistribResult:

      if node is None:
         return CoinsDistribResult(0		,	1      )

      _a		,						_a					:  Optional[Any]						=  get_distrib(node.left      )
      _a		,						_a					:  Tuple						=  get_distrib(node.right      )

      _a					:  List[str]						=  1 - left_distrib_excess
      _a					:  str						=  1 - right_distrib_excess

      _a					:  Any						=  (
          left_distrib_moves
          + right_distrib_moves
          + abs(A      )
          + abs(A      )
      )
      _a					:  Optional[int]						=  node.data - coins_to_left - coins_to_right

      return CoinsDistribResult(A		,	A      )

   return get_distrib(A      )[0]


if __name__ == "__main__":
 import doctest

 doctest.testmod()


