'''simple docstring'''




from dataclasses import dataclass

__SCREAMING_SNAKE_CASE	:					Optional[int]					=  """0.1"""
__SCREAMING_SNAKE_CASE	:					Any					=  """Lucia Harcekova"""

@dataclass
class      lowerCamelCase_     :
      '''simple docstring'''

      __UpperCamelCase:  int
      __UpperCamelCase:  int
      __UpperCamelCase:  str




      def __repr__(	self						:    Dict	):
             return F"""({self.offset}, {self.length}, {self.indicator})"""

class      lowerCamelCase_     :
      '''simple docstring'''

      def __init__(	self						:    Union[str, Any]						, A						:    int = 13						, A						:    int = 6	):
             _UpperCAmelCase					:  Optional[Any]											=   window_size
             _UpperCAmelCase					:  Union[str, Any]											=   lookahead_buffer_size
             _UpperCAmelCase					:  Union[str, Any]											=   self.window_size - self.lookahead_buffer_size




      def 					_A     (	self						:    List[str]						, A						:    str	):
             _UpperCAmelCase					:  List[str]											=   []
             _UpperCAmelCase					:  str											=   ""

             # while there are still characters in text to compress
             while text:
                    # find the next encoding phrase
                    # - triplet with offset, length, indicator (the next encoding character)
                    _UpperCAmelCase					:  Dict											=   self._find_encoding_token(A						, A	)

                    # update the search buffer:
                    # - add new characters from text into it
                    # - check if size exceed the max search buffer size, if so, drop the
                    #   oldest elements
                    search_buffer += text[: token.length + 1]
                    if len(A	) > self.search_buffer_size:
                           _UpperCAmelCase					:  Optional[int]											=   search_buffer[-self.search_buffer_size :]

                    # update the text
                    _UpperCAmelCase					:  Union[str, Any]											=   text[token.length + 1 :]

                    # append the token to output
                    output.append(A	)

             return output




      def 					_A     (	self						:    List[Any]						, A						:    list[Token]	):
             _UpperCAmelCase					:  int											=   ""

             for token in tokens:
                    for _ in range(token.length	):
                           output += output[-token.offset]
                    output += token.indicator

             return output




      def 					_A     (	self						:    List[str]						, A						:    str						, A						:    str	):

             if not text:
                    raise ValueError("We need some text to work with."	)

             # Initialise result parameters to default values
             _UpperCAmelCase					:  Union[str, Any]											=   0, 0

             if not search_buffer:
                    return Token(A						, A						, text[length]	)

             for i, character in enumerate(A	):
                    _UpperCAmelCase					:  Dict											=   len(A	) - i
                    if character == text[0]:
                           _UpperCAmelCase					:  str											=   self._match_length_from_index(A						, A						, 0						, A	)
                           # if the found length is bigger than the current or if it's equal,
                           # which means it's offset is smaller: update offset and length
                           if found_length >= length:
                                  _UpperCAmelCase					:  Union[str, Any]											=   found_offset, found_length

             return Token(A						, A						, text[length]	)





      def 					_A     (	self						:    List[str]						, A						:    str						, A						:    str						, A						:    int						, A						:    int	):
             if not text or text[text_index] != window[window_index]:
                    return 0
             return 1 + self._match_length_from_index(
                 A						, window + text[text_index]						, text_index + 1						, window_index + 1	)


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

   testmod()
   # Initialize compressor class
   __SCREAMING_SNAKE_CASE	:					Optional[Any]					=  LZaaCompressor(window_size=13, lookahead_buffer_size=6)

   # Example
   __SCREAMING_SNAKE_CASE	:					Any					=  """cabracadabrarrarrad"""
   __SCREAMING_SNAKE_CASE	:					str					=  lzaa_compressor.compress(TEXT)
   print(lzaa_compressor.compress("""ababcbababaa"""))
   __SCREAMING_SNAKE_CASE	:					List[Any]					=  lzaa_compressor.decompress(compressed_text)
   assert decompressed_text == TEXT, "The LZ77 algorithm returned the invalid result."


'''simple docstring'''




def      UpperCamelCase_							( _UpperCAmelCase  :				int      ,     _UpperCAmelCase  :				list[tuple[int, int, int]]   )   ->   list[tuple[int, int, int]]:


       """simple docstring"""







       _UpperCAmelCase					:  Optional[int]											=   sorted(_UpperCAmelCase      ,     key=lambda _UpperCAmelCase   : edge[2]   )

       _UpperCAmelCase					:  Optional[int]											=   list(range(_UpperCAmelCase   )   )

       def find_parent(_UpperCAmelCase  :				Dict   ):
              if i != parent[i]:
                     _UpperCAmelCase					:  Tuple											=   find_parent(parent[i]   )
              return parent[i]

       _UpperCAmelCase					:  Union[str, Any]											=   0
       _UpperCAmelCase					:  Dict											=   []

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

       return minimum_spanning_tree


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

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

  kruskal(num_nodes, edges)

