


"""simple docstring"""







import sys
from collections import defaultdict




class 			UpperCamelCase_     :

	"""simple docstring"""





	def __init__(			self      :    int       )	->     Optional[Any]:
						__SCREAMING_SNAKE_CASE						       =    []




	def   UpperCAmelCase_				(			self      :    List[str]      ,      UpperCAmelCase__      :    int       )	->     Any:
						return self.node_position[vertex]




	def   UpperCAmelCase_				(			self      :    Tuple      ,      UpperCAmelCase__      :    List[str]      ,      UpperCAmelCase__      :    Optional[int]       )	->     List[str]:
						__SCREAMING_SNAKE_CASE						       =    pos




	def   UpperCAmelCase_				(			self      :    Optional[Any]      ,      UpperCAmelCase__      :    str      ,      UpperCAmelCase__      :    int      ,      UpperCAmelCase__      :    Union[str, Any]      ,      UpperCAmelCase__      :    Optional[int]       )	->     Any:
						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   UpperCAmelCase_				(			self      :    int      ,      UpperCAmelCase__      :    Tuple      ,      UpperCAmelCase__      :    Union[str, Any]      ,      UpperCAmelCase__      :    Optional[int]      ,      UpperCAmelCase__      :    Union[str, Any]       )	->     Optional[Any]:
						__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   UpperCAmelCase_				(			self      :    int      ,      UpperCAmelCase__      :    List[str]      ,      UpperCAmelCase__      :    List[str]       )	->     Any:
						__SCREAMING_SNAKE_CASE						       =    len(UpperCAmelCase__       ) // 2 - 1
						for i in range(UpperCAmelCase__      ,      -1      ,      -1       ):
											self.top_to_bottom(UpperCAmelCase__      ,      UpperCAmelCase__      ,      len(UpperCAmelCase__       )      ,      UpperCAmelCase__       )




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




def        UpperCAmelCase__	(lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    Heap()

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

					__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(lowerCAmelCase_  ,						lowerCAmelCase_       )

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


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

import requests




def        UpperCAmelCase__	(lowerCAmelCase_       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    f"""https://hacker-news.firebaseio.com/v0/item/{story_id}.json?print=pretty"""
					return requests.get(lowerCAmelCase_       ).json()




def        UpperCAmelCase__	(lowerCAmelCase_ = 10       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
					__SCREAMING_SNAKE_CASE						       =    requests.get(lowerCAmelCase_       ).json()[:max_stories]
					return [get_hackernews_story(lowerCAmelCase_       ) for story_id in story_ids]




def        UpperCAmelCase__	(lowerCAmelCase_ = 10       ):




					'''simple docstring'''


					__SCREAMING_SNAKE_CASE						       =    hackernews_top_stories(lowerCAmelCase_       )
					return "\n".join("* [{title}]({url})".format(**lowerCAmelCase_       ) for story in stories       )


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