


import sys
from collections import defaultdict






class 	UpperCamelCase__:




				def __init__(		self      :			List[Any]				)->					Union[str, Any]:

										"""simple docstring"""




										UpperCAmelCase					    =     []




				def 					a__(		self      :			Optional[Any]				,   lowerCAmelCase      :			List[Any]				)->					Optional[Any]:

										"""simple docstring"""




										return self.node_position[vertex]




				def 					a__(		self      :			Any				,   lowerCAmelCase      :			Tuple				,   lowerCAmelCase      :			Tuple				)->					Dict:

										"""simple docstring"""




										UpperCAmelCase					    =     pos




				def 					a__(		self      :			int				,   lowerCAmelCase      :			int				,   lowerCAmelCase      :			str				,   lowerCAmelCase      :			Dict				,   lowerCAmelCase      :			Optional[Any]				)->					str:

										"""simple docstring"""




										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]				,   lowerCAmelCase				)

																						self.top_to_bottom(lowerCAmelCase				,   lowerCAmelCase				,   lowerCAmelCase				,   lowerCAmelCase				)




				def 					a__(		self      :			Tuple				,   lowerCAmelCase      :			Optional[Any]				,   lowerCAmelCase      :			Optional[Any]				,   lowerCAmelCase      :			Optional[int]				,   lowerCAmelCase      :			Dict				)->					Any:

										"""simple docstring"""




										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]				,   lowerCAmelCase				)
																else:
																						UpperCAmelCase					    =     val
																						UpperCAmelCase					    =     temp
																						self.set_position(lowerCAmelCase				,   lowerCAmelCase				)
																						break
																UpperCAmelCase					    =     parent
										else:
																UpperCAmelCase					    =     val
																UpperCAmelCase					    =     temp
																self.set_position(lowerCAmelCase				,   0				)




				def 					a__(		self      :			Dict				,   lowerCAmelCase      :			Union[str, Any]				,   lowerCAmelCase      :			Union[str, Any]				)->					Optional[Any]:

										"""simple docstring"""




										UpperCAmelCase					    =     len(lowerCAmelCase				) // 2 - 1
										for i in range(lowerCAmelCase				,   -1				,   -1				):
																self.top_to_bottom(lowerCAmelCase				,   lowerCAmelCase				,   len(lowerCAmelCase				)				,   lowerCAmelCase				)





				def 					a__(		self      :			Union[str, Any]				,   lowerCAmelCase      :			Optional[Any]				,   lowerCAmelCase      :			Union[str, Any]				)->					Any:

										"""simple docstring"""




										UpperCAmelCase					    =     positions[0]
										UpperCAmelCase					    =     sys.maxsize
										self.top_to_bottom(lowerCAmelCase				,   0				,   len(lowerCAmelCase				)				,   lowerCAmelCase				)
										return temp







def 				lowerCamelCase__				(	A       :      Union[str, Any]					):




						'''simple docstring'''






						UpperCAmelCase					    =     Heap()

						UpperCAmelCase					    =     [0] * len(A					)
						UpperCAmelCase					    =     [-1] * len(A					)  # 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(A					)					):
												distance_tv.append(sys.maxsize					)
												positions.append(A					)
												heap.node_position.append(A					)

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

						for _ in range(1				,       len(A					)					):
												UpperCAmelCase					    =     heap.delete_minimum(A				,       A					)
												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(A					)]
																								):
																														UpperCAmelCase					    =     distance
																														heap.bottom_to_top(
																														    A				,       heap.get_position(A					)				,       A				,       A					)
																														UpperCAmelCase					    =     vertex
						return tree_edges


if __name__ == "__main__":  # pragma: no cover
	# < --------- Prims Algorithm --------- >
	_lowercase      :      str            =					int(input("""Enter number of edges: """).strip())
	_lowercase      :      Optional[Any]            =					defaultdict(list)
	for _ in range(edges_number):
		_lowercase      :      str            =					[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))









'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase      :      List[str]            =					{
    """configuration_time_series_transformer""": [
        """TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """TimeSeriesTransformerConfig""",
    ],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase      :      Dict            =					[
	    """TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """TimeSeriesTransformerForPrediction""",
	    """TimeSeriesTransformerModel""",
	    """TimeSeriesTransformerPreTrainedModel""",
	]


if TYPE_CHECKING:
	from .configuration_time_series_transformer import (
	    TIME_SERIES_TRANSFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    TimeSeriesTransformerConfig,
	)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_time_series_transformer import (
		    TIME_SERIES_TRANSFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TimeSeriesTransformerForPrediction,
		    TimeSeriesTransformerModel,
		    TimeSeriesTransformerPreTrainedModel,
		)

else:
	import sys

	_lowercase      :      Tuple            =					_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





