



import sys
from collections import defaultdict






class 		lowercase						:






	"""simple docstring"""


	def __init__(     self     :						Optional[Any]					)      ->			Dict:
							UpperCAmelCase_=       []




	def   _SCREAMING_SNAKE_CASE		(     self     :						int						,  __UpperCAmelCase     :						str					)      ->			Union[str, Any]:
							return self.node_position[vertex]




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Optional[int]					)      ->			List[str]:
							UpperCAmelCase_=       pos




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						List[Any]						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						List[str]					)      ->			Union[str, Any]:
							if start > size // 2 - 1:
													return
							else:
													if 2 * start + 2 >= size:
																			UpperCAmelCase_=       2 * start + 1
													else:
																			if heap[2 * start + 1] < heap[2 * start + 2]:
																									UpperCAmelCase_=       2 * start + 1
																			else:
																									UpperCAmelCase_=       2 * start + 2
													if heap[smallest_child] < heap[start]:
																			UpperCAmelCase_,       UpperCAmelCase_=       heap[smallest_child], positions[smallest_child]
																			UpperCAmelCase_,       UpperCAmelCase_=       (
																			    heap[start],
																			    positions[start],
																			)
																			UpperCAmelCase_,       UpperCAmelCase_=       temp, tempa

																			UpperCAmelCase_=       self.get_position(positions[smallest_child]					)
																			self.set_position(
																			    positions[smallest_child]						,  self.get_position(positions[start]					)					)
																			self.set_position(positions[start]						,  __SCREAMING_SNAKE_CASE					)

																			self.top_to_bottom(__SCREAMING_SNAKE_CASE						,  __SCREAMING_SNAKE_CASE						,  __SCREAMING_SNAKE_CASE						,  __SCREAMING_SNAKE_CASE					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						str						,  __UpperCAmelCase     :						str						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						Optional[Any]					)      ->			List[Any]:
							UpperCAmelCase_=       position[index]

							while index != 0:
													UpperCAmelCase_=       int((index - 2) / 2					) if index % 2 == 0 else int((index - 1) / 2					)

													if val < heap[parent]:
																			UpperCAmelCase_=       heap[parent]
																			UpperCAmelCase_=       position[parent]
																			self.set_position(position[parent]						,  __SCREAMING_SNAKE_CASE					)
													else:
																			UpperCAmelCase_=       val
																			UpperCAmelCase_=       temp
																			self.set_position(__SCREAMING_SNAKE_CASE						,  __SCREAMING_SNAKE_CASE					)
																			break
													UpperCAmelCase_=       parent
							else:
													UpperCAmelCase_=       val
													UpperCAmelCase_=       temp
													self.set_position(__SCREAMING_SNAKE_CASE						,  0					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Any						,  __UpperCAmelCase     :						List[str]						,  __UpperCAmelCase     :						Tuple					)      ->			str:
							UpperCAmelCase_=       len(__SCREAMING_SNAKE_CASE					) // 2 - 1
							for i in range(__SCREAMING_SNAKE_CASE						,  -1						,  -1					):
													self.top_to_bottom(__SCREAMING_SNAKE_CASE						,  __SCREAMING_SNAKE_CASE						,  len(__SCREAMING_SNAKE_CASE					)						,  __SCREAMING_SNAKE_CASE					)




	def   _SCREAMING_SNAKE_CASE		(     self     :						Dict						,  __UpperCAmelCase     :						Tuple						,  __UpperCAmelCase     :						Optional[int]					)      ->			Any:
							UpperCAmelCase_=       positions[0]
							UpperCAmelCase_=       sys.maxsize
							self.top_to_bottom(__SCREAMING_SNAKE_CASE						,  0						,  len(__SCREAMING_SNAKE_CASE					)						,  __SCREAMING_SNAKE_CASE					)
							return temp



def 	__a					(   lowerCAmelCase_       : Optional[int]    )				->			int:






						'''simple docstring'''



						UpperCAmelCase_=       Heap()

						UpperCAmelCase_=       [0] * len(lowercase__    )
						UpperCAmelCase_=       [-1] * len(lowercase__    )  # Neighboring Tree Vertex of selected vertex
						# Minimum Distance of explored vertex with neighboring vertex of partial tree
						# formed in graph
						UpperCAmelCase_=       []  # Heap of Distance of vertices from their neighboring vertex
						UpperCAmelCase_=       []

						for vertex in range(len(lowercase__    )    ):
												distance_tv.append(sys.maxsize    )
												positions.append(lowercase__    )
												heap.node_position.append(lowercase__    )

						UpperCAmelCase_=       []
						UpperCAmelCase_=       1
						UpperCAmelCase_=       sys.maxsize
						for neighbor, distance in adjacency_list[0]:
												UpperCAmelCase_=       0
												UpperCAmelCase_=       distance
						heap.heapify(lowercase__      ,lowercase__    )

						for _ in range(1      ,len(lowercase__    )    ):
												UpperCAmelCase_=       heap.delete_minimum(lowercase__      ,lowercase__    )
												if visited[vertex] == 0:
																		tree_edges.append((nbr_tv[vertex], vertex)    )
																		UpperCAmelCase_=       1
																		for neighbor, distance in adjacency_list[vertex]:
																								if (
																								    visited[neighbor] == 0
																								    and distance < distance_tv[heap.get_position(lowercase__    )]
																								):
																														UpperCAmelCase_=       distance
																														heap.bottom_to_top(
																														    lowercase__      ,heap.get_position(lowercase__    )      ,lowercase__      ,lowercase__    )
																														UpperCAmelCase_=       vertex
						return tree_edges


if __name__ == "__main__":  # pragma: no cover
		# < --------- Prims Algorithm --------- >
		__A       =						int(input('''Enter number of edges: ''').strip())
		__A       =						defaultdict(list)
		for _ in range(edges_number):
				__A       =						[int(x) for x in input().strip().split()]
				adjacency_list[edge[0]].append([edge[1], edge[2]])
				adjacency_list[edge[1]].append([edge[0], edge[2]])
		print(prisms_algorithm(adjacency_list))









import math
import time
from typing import Dict, List, Optional

from torch.utils.data import Dataset

from transformers import SeqaSeqTrainer, is_torch_tpu_available
from transformers.trainer_utils import PredictionOutput, speed_metrics


if is_torch_tpu_available(check_device=False):
	import torch_xla.core.xla_model as xm
	import torch_xla.debug.metrics as met






class 		lowercase						(			snake_case__):






	"""simple docstring"""


	def __init__(     self     :						Any						,  *__UpperCAmelCase     :						Union[str, Any]						,  __UpperCAmelCase     :						List[str]=None						,  __UpperCAmelCase     :						Optional[int]=None						,  **__UpperCAmelCase     :						Dict					)      ->			Optional[int]:
							super().__init__(*__UpperCAmelCase						,  **__UpperCAmelCase					)
							UpperCAmelCase_=       eval_examples
							UpperCAmelCase_=       post_process_function




	def   _SCREAMING_SNAKE_CASE		(     self     :						Tuple						,  __UpperCAmelCase     :						Optional[Dataset] = None						,  __UpperCAmelCase     :						Optional[Any]=None						,  __UpperCAmelCase     :						Optional[List[str]] = None						,  __UpperCAmelCase     :						str = "eval"						,  **__UpperCAmelCase     :						Any						,  )      ->			Dict[str, float]:
							UpperCAmelCase_=       gen_kwargs.copy()
							UpperCAmelCase_=       (
							    gen_kwargs["""max_length"""] if gen_kwargs.get("""max_length"""					) is not None else self.args.generation_max_length
							)
							UpperCAmelCase_=       (
							    gen_kwargs["""num_beams"""] if gen_kwargs.get("""num_beams"""					) is not None else self.args.generation_num_beams
							)
							UpperCAmelCase_=       gen_kwargs

							UpperCAmelCase_=       self.eval_dataset if eval_dataset is None else eval_dataset
							UpperCAmelCase_=       self.get_eval_dataloader(__UpperCAmelCase					)
							UpperCAmelCase_=       self.eval_examples if eval_examples is None else eval_examples

							# Temporarily disable metric computation, we will do it in the loop here.
							UpperCAmelCase_=       self.compute_metrics
							UpperCAmelCase_=       None
							UpperCAmelCase_=       time.time()
							UpperCAmelCase_=       self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
							try:
													UpperCAmelCase_=       eval_loop(
													    __UpperCAmelCase						,  description="""Evaluation"""						,  prediction_loss_only=True if compute_metrics is None else None						,  ignore_keys=__UpperCAmelCase						,  metric_key_prefix=__UpperCAmelCase						,  )
							finally:
													UpperCAmelCase_=       compute_metrics
							UpperCAmelCase_=       self.args.eval_batch_size * self.args.world_size
							if F"""{metric_key_prefix}_jit_compilation_time""" in output.metrics:
													start_time += output.metrics[F"""{metric_key_prefix}_jit_compilation_time"""]
							output.metrics.update(
							    speed_metrics(
							        __UpperCAmelCase						,  __UpperCAmelCase						,  num_samples=output.num_samples						,  num_steps=math.ceil(output.num_samples / total_batch_size					)						,  )					)

							if self.post_process_function is not None and self.compute_metrics is not None and self.args.should_save:
													# Only the main node write the results by default
													UpperCAmelCase_=       self.post_process_function(__UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase					)
													UpperCAmelCase_=       self.compute_metrics(__UpperCAmelCase					)

													# Prefix all keys with metric_key_prefix + '_'
													for key in list(metrics.keys()					):
																			if not key.startswith(F"""{metric_key_prefix}_"""					):
																									UpperCAmelCase_=       metrics.pop(__UpperCAmelCase					)

													metrics.update(output.metrics					)
							else:
													UpperCAmelCase_=       output.metrics

							if self.args.should_log:
													# Only the main node log the results by default
													self.log(__UpperCAmelCase					)

							if self.args.tpu_metrics_debug or self.args.debug:
													# tpu-comment: Logging debug metrics for PyTorch/XLA (compile, execute times, ops, etc.)
													xm.master_print(met.metrics_report()					)

							UpperCAmelCase_=       self.callback_handler.on_evaluate(self.args						,  self.state						,  self.control						,  __UpperCAmelCase					)
							return metrics




	def   _SCREAMING_SNAKE_CASE		(     self     :						int						,  __UpperCAmelCase     :						Dict						,  __UpperCAmelCase     :						int						,  __UpperCAmelCase     :						Optional[int]=None						,  __UpperCAmelCase     :						str = "test"						,  **__UpperCAmelCase     :						List[str]					)      ->			Tuple:
							UpperCAmelCase_=       gen_kwargs.copy()

							UpperCAmelCase_=       self.get_test_dataloader(__UpperCAmelCase					)

							# Temporarily disable metric computation, we will do it in the loop here.
							UpperCAmelCase_=       self.compute_metrics
							UpperCAmelCase_=       None
							UpperCAmelCase_=       time.time()
							UpperCAmelCase_=       self.prediction_loop if self.args.use_legacy_prediction_loop else self.evaluation_loop
							try:
													UpperCAmelCase_=       eval_loop(
													    __UpperCAmelCase						,  description="""Prediction"""						,  prediction_loss_only=True if compute_metrics is None else None						,  ignore_keys=__UpperCAmelCase						,  metric_key_prefix=__UpperCAmelCase						,  )
							finally:
													UpperCAmelCase_=       compute_metrics

							UpperCAmelCase_=       self.args.eval_batch_size * self.args.world_size
							if F"""{metric_key_prefix}_jit_compilation_time""" in output.metrics:
													start_time += output.metrics[F"""{metric_key_prefix}_jit_compilation_time"""]
							output.metrics.update(
							    speed_metrics(
							        __UpperCAmelCase						,  __UpperCAmelCase						,  num_samples=output.num_samples						,  num_steps=math.ceil(output.num_samples / total_batch_size					)						,  )					)
							if self.post_process_function is None or self.compute_metrics is None:
													return output

							UpperCAmelCase_=       self.post_process_function(__UpperCAmelCase						,  __UpperCAmelCase						,  __UpperCAmelCase						,  """predict"""					)
							UpperCAmelCase_=       self.compute_metrics(__UpperCAmelCase					)

							# Prefix all keys with metric_key_prefix + '_'
							for key in list(metrics.keys()					):
													if not key.startswith(F"""{metric_key_prefix}_"""					):
																			UpperCAmelCase_=       metrics.pop(__UpperCAmelCase					)
							metrics.update(output.metrics					)
							return PredictionOutput(predictions=predictions.predictions						,  label_ids=predictions.label_ids						,  metrics=__UpperCAmelCase					)




