




'''simple docstring'''







def 						snake_case_							(_a	:							Any     ):
    UpperCAmelCase			       =		[]
    UpperCAmelCase			       =		set({'''(''', '''[''', '''{'''}     )
    UpperCAmelCase			       =		set({''')''', ''']''', '''}'''}     )
    UpperCAmelCase			       =		{'''{''': '''}''', '''[''': ''']''', '''(''': ''')'''}

    for i in range(len(_a     )     ):
        if s[i] in open_brackets:
            stack.append(s[i]     )

        elif s[i] in closed_brackets and (
            len(_a     ) == 0 or (len(_a     ) > 0 and open_to_closed[stack.pop()] != s[i])
        ):
            return False

    return len(_a     ) == 0





def 						snake_case_							():
    UpperCAmelCase			       =		input('''Enter sequence of brackets: '''     )
    if is_balanced(_a     ):
        print(_a    ,   '''is balanced'''     )
    else:
        print(_a    ,   '''is not balanced'''     )


if __name__ == "__main__":
   main()







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()
