

from __future__ import annotations

from typing import Any







class 						__magic_name__			(							lowerCamelCase__							):

   '''simple docstring'''




   pass







class 						__magic_name__			:

   '''simple docstring'''




   def __init__(				self,    lowercase_       )							->    None:






     """simple docstring"""






     a__  =data
     a__  =None



   def __iter__(				self       )							->    List[str]:






     """simple docstring"""






     a__  =self
     a__  =[]
     while node:
       if node in visited:
         raise ContainsLoopError
       visited.append(lowercase_       )
       yield node.data
       a__  =node.next_node



   @property
   def  _UpperCAmelCase (				self       )							->    bool:






     """simple docstring"""






     try:
       list(self       )
       return False
     except ContainsLoopError:
       return True


if __name__ == "__main__":
       lowerCamelCase           =					Node(1)
       lowerCamelCase           =					Node(2)
       lowerCamelCase           =					Node(3)
       lowerCamelCase           =					Node(4)
       print(root_node.has_loop)  # False
       lowerCamelCase           =					root_node.next_node
       print(root_node.has_loop)  # True

       lowerCamelCase           =					Node(5)
       lowerCamelCase           =					Node(6)
       lowerCamelCase           =					Node(5)
       lowerCamelCase           =					Node(6)
       print(root_node.has_loop)  # False

       lowerCamelCase           =					Node(1)
       print(root_node.has_loop)  # False



def 			UpperCAmelCase__				(			_A      : dict							):





  '''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(_A	,      _A	,      _A	,      _A							)
      for node in graph							)




def 			UpperCAmelCase__				(			_A      : dict	,      _A      : int	,      _A      : set	,      _A      : set							):





  '''simple docstring'''







  visited.add(_A							)
  rec_stk.add(_A							)

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

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


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

       testmod()
