




__SCREAMING_SNAKE_CASE    :   List[Any]       ={
    0: """underwear""",
    1: """pants""",
    2: """belt""",
    3: """suit""",
    4: """shoe""",
    5: """socks""",
    6: """shirt""",
    7: """tie""",
    8: """watch""",
}

__SCREAMING_SNAKE_CASE    :   int       =[[1, 4], [2, 4], [3], [], [], [4], [2, 7], [3], []]

__SCREAMING_SNAKE_CASE    :   Optional[int]       =[0 for x in range(len(graph))]
__SCREAMING_SNAKE_CASE    :   Dict       =[]





def 			lowerCAmelCase_			(  lowerCamelCase:       Union[str, Any]     ,				lowerCamelCase:       Any						)					->			Union[str, Any]:


      '''simple docstring'''




      lowerCamelCase__        =				1
      while stack:
            lowerCamelCase__        =				stack.pop()
            print(UpperCAmelCase_     ,				clothes[current_clothing]						)
            order += 1





def 			lowerCAmelCase_			(  lowerCamelCase:       Any     ,				lowerCamelCase:       Any     ,				lowerCamelCase:       int						)					->			Dict:


      '''simple docstring'''




      lowerCamelCase__        =				1
      for v in graph[u]:
            if not visited[v]:
                  depth_first_search(UpperCAmelCase_     ,				UpperCAmelCase_     ,				UpperCAmelCase_						)

      stack.append(UpperCAmelCase_						)





def 			lowerCAmelCase_			(  lowerCamelCase:       Union[str, Any]     ,				lowerCamelCase:       Union[str, Any]						)					->			List[Any]:


      '''simple docstring'''




      for v in range(len(UpperCAmelCase_						)						):
            if not visited[v]:
                  depth_first_search(UpperCAmelCase_     ,				UpperCAmelCase_     ,				UpperCAmelCase_						)


if __name__ == "__main__":
      topological_sort(graph, visited)
      print(stack)
      print_stack(stack, clothes)





def 			lowerCAmelCase_			(  lowerCamelCase:       int     ,				lowerCamelCase:       list[tuple[int, int, int]]						)					->			list[tuple[int, int, int]]:


      '''simple docstring'''




      lowerCamelCase__        =				sorted(lowerCamelCase     ,				key=lambda lowerCamelCase						: edge[2]						)

      lowerCamelCase__        =				list(range(lowerCamelCase						)						)

      def find_parent(lowerCamelCase:       int						):
            if i != parent[i]:
                  lowerCamelCase__        =				find_parent(parent[i]						)
            return parent[i]

      lowerCamelCase__        =				0
      lowerCamelCase__        =				[]

      for edge in edges:
            lowerCamelCase__        =				find_parent(edge[0]						)
            lowerCamelCase__        =				find_parent(edge[1]						)
            if parent_a != parent_b:
                  minimum_spanning_tree_cost += edge[2]
                  minimum_spanning_tree.append(lowerCamelCase						)
                  lowerCamelCase__        =				parent_b

      return minimum_spanning_tree


if __name__ == "__main__":  # pragma: no cover
      __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    :   Tuple       =list(map(int, input().strip().split()))
      __SCREAMING_SNAKE_CASE    :   Optional[Any]       =[]

      for _ in range(num_edges):
            __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    ,  __SCREAMING_SNAKE_CASE    :   Optional[int]       =(int(x) for x in input().strip().split())
            edges.append((nodea, nodea, cost))

      kruskal(num_nodes, edges)