





from typing import Dict, List, Optional, Tuple

from ...tokenization_utils import AddedToken, PreTrainedTokenizer
from ...utils import logging


UpperCAmelCase_   				=  logging.get_logger(__name__)
class       UpperCamelCase_		(	_a       ):
					lowerCAmelCase_				=						["""input_ids""", """attention_mask"""]




					def __init__(		self					,    lowerCAmelCase_="[PAD]"					,    lowerCAmelCase_="[BOS]"					,    lowerCAmelCase_="[EOS]"					,    lowerCAmelCase_="[MASK]"					,    lowerCAmelCase_="[CLS]"					,    lowerCAmelCase_="[SEP]"					,    lowerCAmelCase_=2048					,    **lowerCAmelCase_					,    )		->				str:
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else pad_token
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else bos_token
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else eos_token
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else mask_token
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else cls_token
										_snake_case						=					AddedToken(__UpperCAmelCase					,    lstrip=__UpperCAmelCase					,    rstrip=__UpperCAmelCase	) if isinstance(__UpperCAmelCase					,    __UpperCAmelCase	) else sep_token

										super().__init__(
										    pad_token=__UpperCAmelCase					,    bos_token=__UpperCAmelCase					,    eos_token=__UpperCAmelCase					,    mask_token=__UpperCAmelCase					,    cls_token=__UpperCAmelCase					,    sep_token=__UpperCAmelCase					,    model_max_length=__UpperCAmelCase					,    **__UpperCAmelCase					,    )

										_snake_case						=					2**8  # utf is 8 bits

										# define special tokens dict
										_snake_case						=					{
										    self.pad_token: 0,
										    self.bos_token: 1,
										    self.eos_token: 2,
										    self.mask_token: 3,
										    self.cls_token: 4,
										    self.sep_token: 5,
										}
										_snake_case						=					len(self.special_tokens_encoder	)
										_snake_case						=					{v: k for k, v in self.special_tokens_encoder.items()}




					def 						lowerCAmelCase      (		self	)		->				Tuple:
										_snake_case						=					self.special_tokens_encoder.copy()
										vocab.update(self.added_tokens_encoder	)
										for i in range(self._utf_vocab_size	):
															_snake_case						=					chr(__UpperCAmelCase	)
															_snake_case						=					i + len(self.special_tokens_encoder	)
										return vocab




					@property
					def 						lowerCAmelCase      (		self	)		->				List[Any]:
										return self._utf_vocab_size + self._num_special_tokens




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_ = None					,    lowerCAmelCase_ = False	)		->				Tuple:
										if already_has_special_tokens:
															return super().get_special_tokens_mask(
															    token_ids_a=__UpperCAmelCase					,    token_ids_a=__UpperCAmelCase					,    already_has_special_tokens=__UpperCAmelCase	)

										# normal case: some special tokens
										if token_ids_a is None:
															return [1] + [0] * len(__UpperCAmelCase	) + [1]
										return [1] + ([0] * len(__UpperCAmelCase	)) + [1] + ([0] * len(__UpperCAmelCase	)) + [1]




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_ = None	)		->				Optional[int]:
										if token_ids_a is None:
															return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
										else:
															return [self.cls_token_id] + token_ids_a + [self.sep_token_id] + token_ids_a + [self.sep_token_id]




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_	)		->				Optional[int]:
										_snake_case						=					[chr(__UpperCAmelCase	) for i in text.encode('utf-8'	)]
										return tokens




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_	)		->				str:
										if token in self.special_tokens_encoder:
															_snake_case						=					self.special_tokens_encoder[token]
										elif token in self.added_tokens_encoder:
															_snake_case						=					self.added_tokens_encoder[token]
										elif len(__UpperCAmelCase	) != 1:
															_snake_case						=					self.unk_token_id
										else:
															_snake_case						=					ord(__UpperCAmelCase	) + self._num_special_tokens
										return token_id




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_	)		->				List[str]:
										if index in self.special_tokens_decoder:
															_snake_case						=					self.special_tokens_decoder[index]
										elif index in self.added_tokens_decoder:
															_snake_case						=					self.added_tokens_decoder[index]
										else:
															_snake_case						=					chr(index - self._num_special_tokens	)
										return token




					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_	)		->				Optional[Any]:
										_snake_case						=					B""
										for token in tokens:
															if token in self.special_tokens_decoder:
																				_snake_case						=					self.special_tokens_decoder[token].encode('utf-8'	)
															elif token in self.added_tokens_decoder:
																				_snake_case						=					self.special_tokens_decoder[token].encode('utf-8'	)
															elif token in self.special_tokens_encoder:
																				_snake_case						=					token.encode('utf-8'	)
															elif token in self.added_tokens_encoder:
																				_snake_case						=					token.encode('utf-8'	)
															else:
																				_snake_case						=					bytes([ord(__UpperCAmelCase	)]	)
															bstring += tok_string
										_snake_case						=					bstring.decode('utf-8'					,    errors='replace'	)
										return string






					def 						lowerCAmelCase      (		self					,    lowerCAmelCase_					,    lowerCAmelCase_ = None	)		->				List[Any]:
										return ()







"""simple docstring"""







def 	lowercase     (							A_    ,  A_			)-> list[tuple[int, int, int]]:
  '''simple docstring'''







  a		:						Union[str, Any] 				=     sorted(A_    ,  key=lambda A_			: edge[2]			)

  a		:						List[Any] 				=     list(range(A_			)			)

  def find_parent(A_			):
    if i != parent[i]:
      a		:						Dict 				=     find_parent(parent[i]			)
    return parent[i]

  a		:						Optional[Any] 				=     0
  a		:						Optional[int] 				=     []

  for edge in edges:
    a		:						List[str] 				=     find_parent(edge[0]			)
    a		:						int 				=     find_parent(edge[1]			)
    if parent_a != parent_b:
      minimum_spanning_tree_cost += edge[2]
      minimum_spanning_tree.append(A_			)
      a		:						Tuple 				=     parent_b

  return minimum_spanning_tree


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

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

 kruskal(num_nodes, edges)






