





import sys
from collections import defaultdict



class 					A__   :





      def __init__( self   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   []





      def        __UpperCamelCase( self       ,							A_   ):
       '''simple docstring'''




       return self.node_position[vertex]





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   pos





      def        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




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

         UpperCamelCase	:					Any       	=   self.get_position(positions[smallest_child]   )
         self.set_position(
             positions[smallest_child]       ,							self.get_position(positions[start]   )   )
         self.set_position(positions[start]       ,							A_   )

         self.top_to_bottom(A_       ,							A_       ,							A_       ,							A_   )





      def        __UpperCamelCase( self       ,							A_       ,							A_       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Any       	=   position[index]

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

        if val < heap[parent]:
         UpperCamelCase	:					Dict       	=   heap[parent]
         UpperCamelCase	:					int       	=   position[parent]
         self.set_position(position[parent]       ,							A_   )
        else:
         UpperCamelCase	:					Optional[int]       	=   val
         UpperCamelCase	:					Tuple       	=   temp
         self.set_position(A_       ,							A_   )
         break
        UpperCamelCase	:					List[Any]       	=   parent
       else:
        UpperCamelCase	:					Dict       	=   val
        UpperCamelCase	:					Tuple       	=   temp
        self.set_position(A_       ,							0   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Tuple       	=   len(A_   ) // 2 - 1
       for i in range(A_       ,							-1       ,							-1   ):
        self.top_to_bottom(A_       ,							A_       ,							len(A_   )       ,							A_   )





      def        __UpperCamelCase( self       ,							A_       ,							A_   ):
       '''simple docstring'''




       UpperCamelCase	:					Optional[Any]       	=   positions[0]
       UpperCamelCase	:					Any       	=   sys.maxsize
       self.top_to_bottom(A_       ,							0       ,							len(A_   )       ,							A_   )
       return temp



def 		A_				(     _lowerCAmelCase     )						-> Any:
 UpperCamelCase	:					List[Any]       	=   Heap()

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

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

 UpperCamelCase	:					int       	=   []
 UpperCamelCase	:					Any       	=   1
 UpperCamelCase	:					List[Any]       	=   sys.maxsize
 for neighbor, distance in adjacency_list[0]:
  UpperCamelCase	:					List[Any]       	=   0
  UpperCamelCase	:					int       	=   distance
 heap.heapify(_lowerCAmelCase							,   _lowerCAmelCase     )

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


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







import pytest
import requests

from datasets.utils.file_utils import http_head

from .utils import OfflineSimulationMode, RequestWouldHangIndefinitelyError, offline



@pytest.mark.integration
def 		A_				(     )						-> List[Any]:
 with offline(OfflineSimulationMode.CONNECTION_TIMES_OUT     ):
  with pytest.raises(_lowerCAmelCase     ):
   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 		A_				(     )						-> Tuple:
 with offline(OfflineSimulationMode.CONNECTION_FAILS     ):
  with pytest.raises(requests.exceptions.ConnectionError     ):
   requests.request("GET"							,   "https://huggingface.co"     )



def 		A_				(     )						-> Optional[int]:
 with offline(OfflineSimulationMode.HF_DATASETS_OFFLINE_SET_TO_1     ):
  with pytest.raises(_lowerCAmelCase     ):
   http_head("https://huggingface.co"     )
