




from pathlib import PurePosixPath
from typing import Optional

import fsspec
from fsspec import AbstractFileSystem
from huggingface_hub.hf_api import DatasetInfo

from ..utils.file_utils import get_authentication_headers_for_url
from ..utils.hub import hf_hub_url





class 			lowerCamelCase_				( _SCREAMING_SNAKE_CASE   ):


 '''simple docstring'''







 lowercase_							       =       ""
 lowercase_							       =       "hf-legacy"  # "hf://"" is reserved for hffs



 def __init__(				self    :						List[str]							,							_lowerCAmelCase    :						Optional[DatasetInfo] = None							,							_lowerCAmelCase    :						Optional[str] = None							,							**_lowerCAmelCase    :						Optional[int]							,							):
       super().__init__(self							,							**_lowerCAmelCase		)
       SCREAMING_SNAKE_CASE_      		=     repo_info
       SCREAMING_SNAKE_CASE_      		=     token
       SCREAMING_SNAKE_CASE_      		=     None



 def  lowerCAmelCase_    (				self    :						Tuple		):
       if self.dir_cache is None:
             SCREAMING_SNAKE_CASE_      		=     {}
             for hf_file in self.repo_info.siblings:
                   # TODO(QL): add sizes
                   SCREAMING_SNAKE_CASE_      		=     {
                       'name': hf_file.rfilename,
                       'size': None,
                       'type': 'file',
                   }
                   self.dir_cache.update(
                       {
                           str(_lowerCAmelCase		): {'name': str(_lowerCAmelCase		), 'size': None, 'type': 'directory'}
                           for d in list(PurePosixPath(hf_file.rfilename		).parents		)[:-1]
                       }		)



 def  lowerCAmelCase_    (				self    :						Dict							,							_lowerCAmelCase    :						str							,							_lowerCAmelCase    :						str = "rb"							,							**_lowerCAmelCase    :						Optional[Any]							,							):
       if not isinstance(self.repo_info							,							_lowerCAmelCase		):
             raise NotImplementedError(F"Open is only implemented for dataset repositories, but got {self.repo_info}"		)
       SCREAMING_SNAKE_CASE_      		=     hf_hub_url(self.repo_info.id							,							_lowerCAmelCase							,							revision=self.repo_info.sha		)
       return fsspec.open(
           _lowerCAmelCase							,							mode=_lowerCAmelCase							,							headers=get_authentication_headers_for_url(_lowerCAmelCase							,							use_auth_token=self.token		)							,							client_kwargs={'trust_env': True}							,							).open()



 def  lowerCAmelCase_    (				self    :						str							,							_lowerCAmelCase    :						Optional[Any]							,							**_lowerCAmelCase    :						Any		):
       self._get_dirs()
       SCREAMING_SNAKE_CASE_      		=     self._strip_protocol(_lowerCAmelCase		)
       if path in self.dir_cache:
             return self.dir_cache[path]
       else:
             raise FileNotFoundError(_lowerCAmelCase		)




 def  lowerCAmelCase_    (				self    :						str							,							_lowerCAmelCase    :						List[str]							,							_lowerCAmelCase    :						Union[str, Any]=False							,							**_lowerCAmelCase    :						List[str]		):
       self._get_dirs()
       SCREAMING_SNAKE_CASE_      		=     PurePosixPath(path.strip('/'		)		)
       SCREAMING_SNAKE_CASE_      		=     {}
       for p, f in self.dir_cache.items():
             SCREAMING_SNAKE_CASE_      		=     PurePosixPath(p.strip('/'		)		)
             SCREAMING_SNAKE_CASE_      		=     p.parent
             if root == path:
                   SCREAMING_SNAKE_CASE_      		=     f
       SCREAMING_SNAKE_CASE_      		=     list(paths.values()		)
       if detail:
             return out
       else:
             return sorted(f['name'] for f in out		)



'''simple docstring'''



import sys
from collections import defaultdict





class   UpperCAmelCase_    :





    """simple docstring"""






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







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         return self.node_position[vertex]







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Tuple:
         __lowerCamelCase  :      Optional[int]														=						pos







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	int:
         if start > size // 2 - 1:
              return
         else:
              if 2 * start + 2 >= size:
                   __lowerCamelCase  :      str														=						2 * start + 1
              else:
                   if heap[2 * start + 1] < heap[2 * start + 2]:
                        __lowerCamelCase  :      Optional[Any]														=						2 * start + 1
                   else:
                        __lowerCamelCase  :      int														=						2 * start + 2
              if heap[smallest_child] < heap[start]:
                   __lowerCamelCase							,			__lowerCamelCase  :      Optional[Any]														=						heap[smallest_child], positions[smallest_child]
                   __lowerCamelCase							,			__lowerCamelCase  :      int														=						(
                       heap[start],
                       positions[start],
                   )
                   __lowerCamelCase							,			__lowerCamelCase  :      str														=						temp, tempa

                   __lowerCamelCase  :      Dict														=						self.get_position(positions[smallest_child]      )
                   self.set_position(
                       positions[smallest_child]     ,	self.get_position(positions[start]      )      )
                   self.set_position(positions[start]     ,	SCREAMING_SNAKE_CASE_      )

                   self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Any:
         __lowerCamelCase  :      Any														=						position[index]

         while index != 0:
              __lowerCamelCase  :      Union[str, Any]														=						int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

              if val < heap[parent]:
                   __lowerCamelCase  :      Union[str, Any]														=						heap[parent]
                   __lowerCamelCase  :      Any														=						position[parent]
                   self.set_position(position[parent]     ,	SCREAMING_SNAKE_CASE_      )
              else:
                   __lowerCamelCase  :      Tuple														=						val
                   __lowerCamelCase  :      List[str]														=						temp
                   self.set_position(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )
                   break
              __lowerCamelCase  :      Tuple														=						parent
         else:
              __lowerCamelCase  :      Union[str, Any]														=						val
              __lowerCamelCase  :      Tuple														=						temp
              self.set_position(SCREAMING_SNAKE_CASE_     ,	0      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	Optional[int]:
         __lowerCamelCase  :      Optional[int]														=						len(SCREAMING_SNAKE_CASE_      ) // 2 - 1
         for i in range(SCREAMING_SNAKE_CASE_     ,	-1     ,	-1      ):
              self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_     ,	len(SCREAMING_SNAKE_CASE_      )     ,	SCREAMING_SNAKE_CASE_      )







    def  lowercase_							(				self     ,	SCREAMING_SNAKE_CASE_     ,	SCREAMING_SNAKE_CASE_      )							->	List[Any]:
         __lowerCamelCase  :      Any														=						positions[0]
         __lowerCamelCase  :      Union[str, Any]														=						sys.maxsize
         self.top_to_bottom(SCREAMING_SNAKE_CASE_     ,	0     ,	len(SCREAMING_SNAKE_CASE_      )     ,	SCREAMING_SNAKE_CASE_      )
         return temp







def      UpperCAmelCase__   (      UpperCAmelCase_       :							Optional[int]				)	->						str:
     __lowerCamelCase  :      List[Any]														=						Heap()

     __lowerCamelCase  :      Optional[int]														=						[0] * len(UpperCAmelCase_				)
     __lowerCamelCase  :      str														=						[-1] * len(UpperCAmelCase_				)  # Neighboring Tree Vertex of selected vertex
     # Minimum Distance of explored vertex with neighboring vertex of partial tree
     # formed in graph
     __lowerCamelCase  :      List[str]														=						[]  # Heap of Distance of vertices from their neighboring vertex
     __lowerCamelCase  :      Tuple														=						[]

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

     __lowerCamelCase  :      Tuple														=						[]
     __lowerCamelCase  :      Dict														=						1
     __lowerCamelCase  :      str														=						sys.maxsize
     for neighbor, distance in adjacency_list[0]:
          __lowerCamelCase  :      Any														=						0
          __lowerCamelCase  :      Any														=						distance
     heap.heapify(UpperCAmelCase_ ,       UpperCAmelCase_				)

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


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






