
'''simple docstring'''






class   SCREAMING_SNAKE_CASE_		:



 def __init__(  self   ,		A ):






        '''simple docstring'''




        lowercase  :		List[str]						=      data
        lowercase  :		Dict						=      None
        lowercase  :		str						=      None





 def __str__(  self ):






        '''simple docstring'''




        return f"""{self.data}"""






class   SCREAMING_SNAKE_CASE_		:



 def __init__(  self ):






        '''simple docstring'''




        lowercase  :		Optional[Any]						=      None
        lowercase  :		Union[str, Any]						=      None



 def __iter__(  self ):






        '''simple docstring'''




        lowercase  :		Optional[Any]						=      self.head
        while node:
               yield node.data
               lowercase  :		List[str]						=      node.next



 def __str__(  self ):






        '''simple docstring'''




        return "->".join([str(A ) for item in self] )



 def __len__(  self ):






        '''simple docstring'''




        return sum(1 for _ in self )



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        self.insert_at_nth(0   ,		A )



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        self.insert_at_nth(len(self )   ,		A )



 def    SCREAMING_SNAKE_CASE(  self   ,		A   ,		A ):






        '''simple docstring'''




        lowercase  :		str						=      len(self )

        if not 0 <= index <= length:
               raise IndexError('''list index out of range''' )
        lowercase  :		int						=      Node(A )
        if self.head is None:
               lowercase  :		Union[str, Any]						=      new_node
        elif index == 0:
               lowercase  :		Any						=      new_node
               lowercase  :		Any						=      self.head
               lowercase  :		List[str]						=      new_node
        elif index == length:
               lowercase  :		Tuple						=      new_node
               lowercase  :		Optional[Any]						=      self.tail
               lowercase  :		Optional[int]						=      new_node
        else:
               lowercase  :		Union[str, Any]						=      self.head
               for _ in range(0   ,		A ):
                      lowercase  :		Any						=      temp.next
               lowercase  :		int						=      new_node
               lowercase  :		List[Any]						=      temp.previous
               lowercase  :		Dict						=      temp
               lowercase  :		Tuple						=      new_node



 def    SCREAMING_SNAKE_CASE(  self ):






        '''simple docstring'''




        return self.delete_at_nth(0 )



 def    SCREAMING_SNAKE_CASE(  self ):






        '''simple docstring'''




        return self.delete_at_nth(len(self ) - 1 )



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        lowercase  :		str						=      len(self )

        if not 0 <= index <= length - 1:
               raise IndexError('''list index out of range''' )
        lowercase  :		Tuple						=      self.head  # default first node
        if length == 1:
               lowercase  :		Union[str, Any]						=      None
        elif index == 0:
               lowercase  :		Dict						=      self.head.next
               lowercase  :		Tuple						=      None
        elif index == length - 1:
               lowercase  :		int						=      self.tail
               lowercase  :		Any						=      self.tail.previous
               lowercase  :		List[str]						=      None
        else:
               lowercase  :		str						=      self.head
               for _ in range(0   ,		A ):
                      lowercase  :		str						=      temp.next
               lowercase  :		List[Any]						=      temp
               lowercase  :		Optional[Any]						=      temp.previous
               lowercase  :		Dict						=      temp.next
        return delete_node.data



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        lowercase  :		str						=      self.head

        while current.data != data:  # Find the position to delete
               if current.next:
                      lowercase  :		int						=      current.next
               else:  # We have reached the end an no value matches
                      raise ValueError('''No data matching given value''' )

        if current == self.head:
               self.delete_head()

        elif current == self.tail:
               self.delete_tail()

        else:  # Before: 1 <--> 2(current) <--> 3
               lowercase  :		Optional[Any]						=      current.next  # 1 --> 3
               lowercase  :		List[str]						=      current.previous  # 1 <--> 3
        return data





 def    SCREAMING_SNAKE_CASE(  self ):






        '''simple docstring'''




        return len(self ) == 0






def 		a_( )				->None:






       '''simple docstring'''




       lowercase  :		str						=      DoublyLinkedList()
       assert linked_list.is_empty() is True
       assert str(lowerCamelCase      ) == ""

       try:
              linked_list.delete_head()
              raise AssertionError  # This should not happen.
       except IndexError:
              assert True  # This should happen.

       try:
              linked_list.delete_tail()
              raise AssertionError  # This should not happen.
       except IndexError:
              assert True  # This should happen.

       for i in range(10      ):
              assert len(lowerCamelCase      ) == i
              linked_list.insert_at_nth(lowerCamelCase   ,				i + 1      )
       assert str(lowerCamelCase      ) == "->".join(str(lowerCamelCase      ) for i in range(1   ,				11      )      )

       linked_list.insert_at_head(0      )
       linked_list.insert_at_tail(11      )
       assert str(lowerCamelCase      ) == "->".join(str(lowerCamelCase      ) for i in range(0   ,				12      )      )

       assert linked_list.delete_head() == 0
       assert linked_list.delete_at_nth(9      ) == 10
       assert linked_list.delete_tail() == 11
       assert len(lowerCamelCase      ) == 9
       assert str(lowerCamelCase      ) == "->".join(str(lowerCamelCase      ) for i in range(1   ,				10      )      )


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

      testmod()










'''simple docstring'''






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






       '''simple docstring'''




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

       lowercase  :		str						=      list(range(lowerCamelCase      )      )

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

       lowercase  :		Union[str, Any]						=      0
       lowercase  :		Any						=      []

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

       return minimum_spanning_tree


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

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

      kruskal(num_nodes, edges)




