'''simple docstring'''





from typing import List

from tokenizers import NormalizedString, PreTokenizedString, normalizers







class 			__snake_case   :
 def __init__(  self		,   snake_case__						)	->							None:
       '''simple docstring'''





       UpperCAmelCase    : List[Any]      =vocab
       UpperCAmelCase    : Tuple      =normalizers.BertNormalizer(
           clean_text=snake_case__		,   handle_chinese_chars=snake_case__		,   strip_accents=snake_case__		,   lowercase=snake_case__		,   )
       try:
             import rjieba
       except ImportError:
             raise ImportError(
                 '''You need to install rjieba to use RoFormerTokenizer. '''
                 '''See https://pypi.org/project/rjieba/ for installation.'''						)
       UpperCAmelCase    : Optional[Any]      =rjieba
 def 	UpperCAmelCase__       (  self		,   snake_case__		,   snake_case__						)	->							List[NormalizedString]:
       '''simple docstring'''





       UpperCAmelCase    : Any      =[]

       # this code slice normalized_string is too slow (6s) but test_alignement_methods can pass
       for token, start, end in self.jieba.tokenize(str(snake_case__						)		,   hmm=snake_case__						):
             if token in self.vocab:
                   splits.append(normalized_string[start:end]						)
             else:
                   UpperCAmelCase    : Any      =self.normalizers.normalize_str(snake_case__						).split()
                   for token in token_list:
                         if token:
                               UpperCAmelCase    : Optional[Any]      =start + len(snake_case__						)
                               splits.append(normalized_string[start:end]						)
                               UpperCAmelCase    : str      =end

        # this code test_alignement_methods can't pass but fast (300ms)
        # for token in self.jieba.cut(str(normalized_string), False):
        #     if token in self.vocab:
        #         splits.append(NormalizedString(token))
        #     else:
        #         token_list = self.normalizers.normalize_str(token).split()
        #         for token in token_list:
        #             if token:
        #                 splits.append(NormalizedString(token))

       return splits






 def 	UpperCAmelCase__       (  self		,   snake_case__						)	->							Optional[int]:
       '''simple docstring'''





       pretok.split(self.jieba_split						)

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






      '''simple docstring'''





      UpperCAmelCase    : List[Any]      =sorted(__lowerCAmelCase		,					key=lambda __lowerCAmelCase						: edge[2]						)

      UpperCAmelCase    : Union[str, Any]      =list(range(__lowerCAmelCase						)						)

      def find_parent(__lowerCAmelCase						):
            if i != parent[i]:
                  UpperCAmelCase    : Optional[int]      =find_parent(parent[i]						)
            return parent[i]

      UpperCAmelCase    : Optional[Any]      =0
      UpperCAmelCase    : List[str]      =[]

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

      return minimum_spanning_tree


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

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

     kruskal(num_nodes, edges)
