
import sys
from collections import defaultdict




class 						lowercase__  :
	def __init__(			self							:   str							):
						SCREAMING_SNAKE_CASE__													= []
	def      A_				(			self							:   Tuple       ,   UpperCAmelCase_							:   List[str]							):
						return self.node_position[vertex]
	def      A_				(			self							:   List[str]       ,   UpperCAmelCase_							:   Any       ,   UpperCAmelCase_							:   Optional[Any]							):
						SCREAMING_SNAKE_CASE__													= pos
	def      A_				(			self							:   List[Any]       ,   UpperCAmelCase_							:   Optional[Any]       ,   UpperCAmelCase_							:   List[str]       ,   UpperCAmelCase_							:   str       ,   UpperCAmelCase_							:   Tuple							):
						if start > size // 2 - 1:
											return
						else:
											if 2 * start + 2 >= size:
																SCREAMING_SNAKE_CASE__													= 2 * start + 1
											else:
																if heap[2 * start + 1] < heap[2 * start + 2]:
																					SCREAMING_SNAKE_CASE__													= 2 * start + 1
																else:
																					SCREAMING_SNAKE_CASE__													= 2 * start + 2
											if heap[smallest_child] < heap[start]:
																SCREAMING_SNAKE_CASE__						, SCREAMING_SNAKE_CASE__													= heap[smallest_child], positions[smallest_child]
																SCREAMING_SNAKE_CASE__						, SCREAMING_SNAKE_CASE__													= (
																    heap[start],
																    positions[start],
																)
																SCREAMING_SNAKE_CASE__						, SCREAMING_SNAKE_CASE__													= temp, tempa

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

																self.top_to_bottom(UpperCAmelCase_       ,   UpperCAmelCase_       ,   UpperCAmelCase_       ,   UpperCAmelCase_							)
	def      A_				(			self							:   List[str]       ,   UpperCAmelCase_							:   Optional[int]       ,   UpperCAmelCase_							:   Union[str, Any]       ,   UpperCAmelCase_							:   Any       ,   UpperCAmelCase_							:   Optional[int]							):
						SCREAMING_SNAKE_CASE__													= position[index]

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

											if val < heap[parent]:
																SCREAMING_SNAKE_CASE__													= heap[parent]
																SCREAMING_SNAKE_CASE__													= position[parent]
																self.set_position(position[parent]       ,   UpperCAmelCase_							)
											else:
																SCREAMING_SNAKE_CASE__													= val
																SCREAMING_SNAKE_CASE__													= temp
																self.set_position(UpperCAmelCase_       ,   UpperCAmelCase_							)
																break
											SCREAMING_SNAKE_CASE__													= parent
						else:
											SCREAMING_SNAKE_CASE__													= val
											SCREAMING_SNAKE_CASE__													= temp
											self.set_position(UpperCAmelCase_       ,   0							)
	def      A_				(			self							:   str       ,   UpperCAmelCase_							:   Any       ,   UpperCAmelCase_							:   Optional[int]							):
						SCREAMING_SNAKE_CASE__													= len(UpperCAmelCase_							) // 2 - 1
						for i in range(UpperCAmelCase_       ,   -1       ,   -1							):
											self.top_to_bottom(UpperCAmelCase_       ,   UpperCAmelCase_       ,   len(UpperCAmelCase_							)       ,   UpperCAmelCase_							)





	def      A_				(			self							:   List[Any]       ,   UpperCAmelCase_							:   Optional[int]       ,   UpperCAmelCase_							:   List[str]							):
						SCREAMING_SNAKE_CASE__													= positions[0]
						SCREAMING_SNAKE_CASE__													= sys.maxsize
						self.top_to_bottom(UpperCAmelCase_       ,   0       ,   len(UpperCAmelCase_							)       ,   UpperCAmelCase_							)
						return temp






def 							_lowercase							(     UpperCamelCase_		)		->		Tuple:
					'''simple docstring'''


					SCREAMING_SNAKE_CASE__													= Heap()

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

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

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

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


if __name__ == "__main__":  # pragma: no cover
				# < --------- Prims Algorithm --------- >
				__snake_case								=  int(input("""Enter number of edges: """).strip())
				__snake_case								=  defaultdict(list)
				for _ in range(edges_number):
								__snake_case								=  [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 os
from math import logaa






def 							_lowercase							(     UpperCamelCase_ = "base_exp.txt"		)		->		int:
					'''simple docstring'''


					SCREAMING_SNAKE_CASE__													= 0
					SCREAMING_SNAKE_CASE__													= 0
					for i, line in enumerate(open(os.path.join(os.path.dirname(UpperCamelCase_		)	,	UpperCamelCase_		)		)		):
										SCREAMING_SNAKE_CASE__						, SCREAMING_SNAKE_CASE__													= list(map(UpperCamelCase_	,	line.split(','		)		)		)
										if x * logaa(UpperCamelCase_		) > largest:
															SCREAMING_SNAKE_CASE__													= x * logaa(UpperCamelCase_		)
															SCREAMING_SNAKE_CASE__													= i + 1
					return result


if __name__ == "__main__":
				print(solution())





