




'''simple docstring'''






from dataclasses import dataclass

lowercase	:      Any				=       '''0.1'''
lowercase	:      int				=       '''Lucia Harcekova'''

@dataclass
class   SCREAMING_SNAKE_CASE_		:
 __snake_case	:     int
 __snake_case	:     int
 __snake_case	:     str



 def __repr__(  self ):






        '''simple docstring'''




        return f"""({self.offset}, {self.length}, {self.indicator})"""






class   SCREAMING_SNAKE_CASE_		:



 def __init__(  self   ,		A = 13   ,		A = 6 ):






        '''simple docstring'''




        lowercase  :		str						=      window_size
        lowercase  :		Tuple						=      lookahead_buffer_size
        lowercase  :		Union[str, Any]						=      self.window_size - self.lookahead_buffer_size



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        lowercase  :		Optional[int]						=      []
        lowercase  :		Union[str, Any]						=      ''''''

        # 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)
               lowercase  :		int						=      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:
                      lowercase  :		List[str]						=      search_buffer[-self.search_buffer_size :]

               # update the text
               lowercase  :		Tuple						=      text[token.length + 1 :]

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

        return output



 def    SCREAMING_SNAKE_CASE(  self   ,		A ):






        '''simple docstring'''




        lowercase  :		Dict						=      ''''''

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

        return output



 def    SCREAMING_SNAKE_CASE(  self   ,		A   ,		A ):






        '''simple docstring'''




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

        # Initialise result parameters to default values
        lowercase,     lowercase  :		Any						=      0, 0

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

        for i, character in enumerate(A ):
               lowercase  :		str						=      len(A ) - i
               if character == text[0]:
                      lowercase  :		Dict						=      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:
                             lowercase,     lowercase  :		List[Any]						=      found_offset, found_length

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





 def    SCREAMING_SNAKE_CASE(  self   ,		A   ,		A   ,		A   ,		A ):






        '''simple docstring'''




        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
      lowercase	:      Union[str, Any]				=       LZaaCompressor(window_size=13, lookahead_buffer_size=6)

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










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




