'''simple docstring'''




from ...configuration_utils import PretrainedConfig
from ...utils import logging


__SCREAMING_SNAKE_CASE	:					Optional[Any]					=  logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE	:					Any					=  {
    """bert-base-uncased""": """https://huggingface.co/bert-base-uncased/resolve/main/config.json""",
    # QDQBERT models can be loaded from any BERT checkpoint, available at https://huggingface.co/models?filter=bert
}

class      lowerCamelCase_     (SCREAMING_SNAKE_CASE_   ):
      '''simple docstring'''

      __UpperCamelCase:  Union[str, Any]      =						"qdqbert"




      def __init__(	self						:    List[Any]						, A						:    Optional[Any]=30522						, A						:    Any=768						, A						:    Optional[Any]=12						, A						:    Any=12						, A						:    Any=3072						, A						:    int="gelu"						, A						:    str=0.1						, A						:    Tuple=0.1						, A						:    Optional[int]=512						, A						:    Optional[int]=2						, A						:    Optional[Any]=0.02						, A						:    Optional[Any]=1E-12						, A						:    Dict=True						, A						:    Tuple=1						, A						:    Optional[int]=0						, A						:    str=2						, **A						:    Optional[Any]						, ):
             super().__init__(pad_token_id=lowercase_						, bos_token_id=lowercase_						, eos_token_id=lowercase_						, **lowercase_	)

             _UpperCAmelCase					:  Union[str, Any]											=   vocab_size
             _UpperCAmelCase					:  Tuple											=   max_position_embeddings
             _UpperCAmelCase					:  Union[str, Any]											=   hidden_size
             _UpperCAmelCase					:  List[str]											=   num_hidden_layers
             _UpperCAmelCase					:  List[Any]											=   num_attention_heads
             _UpperCAmelCase					:  Optional[Any]											=   intermediate_size
             _UpperCAmelCase					:  Dict											=   hidden_act
             _UpperCAmelCase					:  List[str]											=   hidden_dropout_prob
             _UpperCAmelCase					:  List[Any]											=   attention_probs_dropout_prob
             _UpperCAmelCase					:  List[Any]											=   initializer_range
             _UpperCAmelCase					:  Optional[Any]											=   type_vocab_size
             _UpperCAmelCase					:  Optional[int]											=   layer_norm_eps
             _UpperCAmelCase					:  Dict											=   use_cache


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

