





import sys
from collections import defaultdict
class     UpperCamelCase__					:






		'''simple docstring'''






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






									"""simple docstring"""
									lowercase_	:   List[Any]  				=     []






		def 						snake_case__				(							self,   snake_case__  )       -> Optional[int]:






									"""simple docstring"""
									return self.node_position[vertex]






		def 						snake_case__				(							self,   snake_case__,   snake_case__  )       -> str:






									"""simple docstring"""
									lowercase_	:   List[Any]  				=     pos






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__  )       -> List[str]:






									"""simple docstring"""
									if start > size // 2 - 1:
																return
									else:
																if 2 * start + 2 >= size:
																							lowercase_	:   int  				=     2 * start + 1
																else:
																							if heap[2 * start + 1] < heap[2 * start + 2]:
																														lowercase_	:   Tuple  				=     2 * start + 1
																							else:
																														lowercase_	:   Union[str, Any]  				=     2 * start + 2
																if heap[smallest_child] < heap[start]:
																							lowercase_				,		lowercase_	:   Optional[int]  				=     heap[smallest_child], positions[smallest_child]
																							lowercase_				,		lowercase_	:   Tuple  				=     (
																							    heap[start],
																							    positions[start],
																							)
																							lowercase_				,		lowercase_	:   List[str]  				=     temp, tempa

																							lowercase_	:   Union[str, Any]  				=     self.get_position(positions[smallest_child]  )
																							self.set_position(
																							    positions[smallest_child],   self.get_position(positions[start]  )  )
																							self.set_position(positions[start],   snake_case__  )

																							self.top_to_bottom(snake_case__,   snake_case__,   snake_case__,   snake_case__  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__,   snake_case__,   snake_case__  )       -> Tuple:






									"""simple docstring"""
									lowercase_	:   Optional[Any]  				=     position[index]

									while index != 0:
																lowercase_	:   List[Any]  				=     int((index - 2) / 2  ) if index % 2 == 0 else int((index - 1) / 2  )

																if val < heap[parent]:
																							lowercase_	:   Optional[int]  				=     heap[parent]
																							lowercase_	:   List[str]  				=     position[parent]
																							self.set_position(position[parent],   snake_case__  )
																else:
																							lowercase_	:   str  				=     val
																							lowercase_	:   Union[str, Any]  				=     temp
																							self.set_position(snake_case__,   snake_case__  )
																							break
																lowercase_	:   List[Any]  				=     parent
									else:
																lowercase_	:   int  				=     val
																lowercase_	:   Optional[int]  				=     temp
																self.set_position(snake_case__,   0  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__  )       -> Any:






									"""simple docstring"""
									lowercase_	:   Union[str, Any]  				=     len(snake_case__  ) // 2 - 1
									for i in range(snake_case__,   -1,   -1  ):
																self.top_to_bottom(snake_case__,   snake_case__,   len(snake_case__  ),   snake_case__  )






		def 						snake_case__				(							self,   snake_case__,   snake_case__  )       -> Tuple:






									"""simple docstring"""
									lowercase_	:   Any  				=     positions[0]
									lowercase_	:   List[str]  				=     sys.maxsize
									self.top_to_bottom(snake_case__,   0,   len(snake_case__  ),   snake_case__  )
									return temp





def  __magic_name__  (				lowercase				)				-> Tuple:

							"""simple docstring"""



							lowercase_	:   str  				=     Heap()

							lowercase_	:   Dict  				=     [0] * len(lowercase				)
							lowercase_	:   Optional[Any]  				=     [-1] * len(lowercase				)  # Neighboring Tree Vertex of selected vertex
							# Minimum Distance of explored vertex with neighboring vertex of partial tree
							# formed in graph
							lowercase_	:   int  				=     []  # Heap of Distance of vertices from their neighboring vertex
							lowercase_	:   Union[str, Any]  				=     []

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

							lowercase_	:   Union[str, Any]  				=     []
							lowercase_	:   str  				=     1
							lowercase_	:   int  				=     sys.maxsize
							for neighbor, distance in adjacency_list[0]:
														lowercase_	:   Tuple  				=     0
														lowercase_	:   List[Any]  				=     distance
							heap.heapify(lowercase				,       lowercase				)

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


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

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline





@pytest.mark.integration
def  __magic_name__  (				)				-> Union[str, Any]:

							"""simple docstring"""



							with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT				):
														with pytest.raises(lowercase				):
																					requests.request("""GET"""				,       """https://huggingface.co"""				)
														with pytest.raises(requests.exceptions.ConnectTimeout				):
																					requests.request("""GET"""				,       """https://huggingface.co"""				,       timeout=1.0				)





@pytest.mark.integration
def  __magic_name__  (				)				-> Union[str, Any]:

							"""simple docstring"""



							with offline(OfflineSimulationMode.CONNECTION_FAILS				):
														with pytest.raises(requests.exceptions.ConnectionError				):
																					requests.request("""GET"""				,       """https://huggingface.co"""				)





def  __magic_name__  (				)				-> Dict:

							"""simple docstring"""



							with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1				):
														with pytest.raises(lowercase				):
																					http_head("""https://huggingface.co"""				)