


import sys
from collections import defaultdict







class      lowerCAmelCase__       :




     '''simple docstring'''


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


     def  _lowerCamelCase (						self ,						__lowerCamelCase)			->				Optional[int]:
            return self.node_position[vertex]


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				int:
            _A      :       Tuple				    = pos


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

                          _A      :       Optional[Any]				    = self.get_position(positions[smallest_child])
                          self.set_position(
                              positions[smallest_child] ,						self.get_position(positions[start]))
                          self.set_position(positions[start] ,						__lowerCamelCase)

                          self.top_to_bottom(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)			->				Optional[Any]:
            _A      :       Union[str, Any]				    = position[index]

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

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


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				List[str]:
            _A      :       str				    = len(__lowerCamelCase) // 2 - 1
            for i in range(__lowerCamelCase ,						-1 ,						-1):
                   self.top_to_bottom(__lowerCamelCase ,						__lowerCamelCase ,						len(__lowerCamelCase) ,						__lowerCamelCase)


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase)			->				Optional[int]:
            _A      :       Tuple				    = positions[0]
            _A      :       List[str]				    = sys.maxsize
            self.top_to_bottom(__lowerCamelCase ,						0 ,						len(__lowerCamelCase) ,						__lowerCamelCase)
            return temp




def 							_UpperCAmelCase				(UpperCamelCase__     :  Optional[Any]						):
       _A      :       int				    = Heap()

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

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

       _A      :       Any				    = []
       _A      :       Dict				    = 1
       _A      :       int				    = sys.maxsize
       for neighbor, distance in adjacency_list[0]:
              _A      :       Union[str, Any]				    = 0
              _A      :       Optional[Any]				    = distance
       heap.heapify(UpperCamelCase__				,							UpperCamelCase__						)

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


if __name__ == "__main__":  # pragma: no cover
    # < --------- Prims Algorithm --------- >
    lowerCAmelCase__      		= int(input('Enter number of edges: ').strip())
    lowerCAmelCase__      		= defaultdict(list)
    for _ in range(edges_number):
        lowerCAmelCase__      		= [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 collections import Counter
from pathlib import Path
from typing import Optional, Tuple

import yaml







class        UpperCamelCase		(			yaml.SafeLoader  ):
   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase			)	->      Optional[int]:


        '''simple docstring'''


        lowercase_	:				str													=	[self.constructed_objects[key_node] for key_node, _ in node.value]
        lowercase_	:				str													=	[tuple(__UpperCamelCase			) if isinstance(__UpperCamelCase     ,__UpperCamelCase			) else key for key in keys]
        lowercase_	:				List[Any]													=	Counter(__UpperCamelCase			)
        lowercase_	:				str													=	[key for key in counter if counter[key] > 1]
        if duplicate_keys:
             raise TypeError(f'''Got duplicate yaml keys: {duplicate_keys}'''			)







   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase     ,__UpperCamelCase=False			)	->      List[Any]:


        '''simple docstring'''


        lowercase_	:				Optional[int]													=	super().construct_mapping(__UpperCamelCase     ,deep=__UpperCamelCase			)
        self._check_no_duplicates_on_constructed_node(__UpperCamelCase			)
        return mapping






def 			lowercase__(       __SCREAMING_SNAKE_CASE							:     str      ):
     lowercase_	:				Tuple													=	list(readme_content.splitlines()      )
     if full_content and full_content[0] == "---" and "---" in full_content[1:]:
          lowercase_	:				Dict													=	full_content[1:].index('---'      ) + 1
          lowercase_	:				Optional[int]													=	'\n'.join(full_content[1:sep_idx]      )
          return yamlblock, "\n".join(full_content[sep_idx + 1 :]      )

     return None, "\n".join(__SCREAMING_SNAKE_CASE      )







class        UpperCamelCase		(			lowercase_  ):
   # class attributes
   lowercase							=  {'train_eval_index'}  # train-eval-index in the YAML metadata
   @classmethod
   def 			_UpperCAmelCase   (			cls     ,__UpperCamelCase			)	->      "DatasetMetadata":


        '''simple docstring'''


        with open(__UpperCamelCase     ,encoding='utf-8'			) as readme_file:
             lowercase_							,  lowercase_	:				Optional[int]													=	_split_yaml_from_readme(readme_file.read()			)
        if yaml_string is not None:
             return cls.from_yaml_string(__UpperCamelCase			)
        else:
             return cls()
   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase			)	->      List[Any]:


        '''simple docstring'''


        if path.exists():
             with open(__UpperCamelCase     ,encoding='utf-8'			) as readme_file:
                  lowercase_	:				Dict													=	readme_file.read()
        else:
             lowercase_	:				int													=	None
        lowercase_	:				Any													=	self._to_readme(__UpperCamelCase			)
        with open(__UpperCamelCase     ,'w'     ,encoding='utf-8'			) as readme_file:
             readme_file.write(__UpperCamelCase			)
   def 			_UpperCAmelCase   (			self     ,__UpperCamelCase = None			)	->      str:


        '''simple docstring'''


        if readme_content is not None:
             lowercase_							,  lowercase_	:				Optional[Any]													=	_split_yaml_from_readme(__UpperCamelCase			)
             lowercase_	:				Optional[Any]													=	'---\n' + self.to_yaml_string() + '---\n' + content
        else:
             lowercase_	:				Tuple													=	'---\n' + self.to_yaml_string() + '---\n'
        return full_content
   @classmethod
   def 			_UpperCAmelCase   (			cls     ,__UpperCamelCase			)	->      "DatasetMetadata":


        '''simple docstring'''


        lowercase_	:				List[str]													=	yaml.load(__UpperCamelCase     ,Loader=_NoDuplicateSafeLoader			) or {}

        # Convert the YAML keys to DatasetMetadata fields
        lowercase_	:				Dict													=	{
            (key.replace('-'     ,'_'			) if key.replace('-'     ,'_'			) in cls._FIELDS_WITH_DASHES else key): value
            for key, value in metadata_dict.items()
        }
        return cls(**__UpperCamelCase			)







   def 			_UpperCAmelCase   (			self			)	->      str:


        '''simple docstring'''


        return yaml.safe_dump(
            {
                (key.replace('_'     ,'-'			) if key in self._FIELDS_WITH_DASHES else key): value
                for key, value in self.items()
            }     ,sort_keys=__UpperCamelCase     ,allow_unicode=__UpperCamelCase     ,encoding='utf-8'     ,).decode('utf-8'			)






__SCREAMING_SNAKE_CASE    	={
    "image-classification": [],
    "translation": [],
    "image-segmentation": [],
    "fill-mask": [],
    "automatic-speech-recognition": [],
    "token-classification": [],
    "sentence-similarity": [],
    "audio-classification": [],
    "question-answering": [],
    "summarization": [],
    "zero-shot-classification": [],
    "table-to-text": [],
    "feature-extraction": [],
    "other": [],
    "multiple-choice": [],
    "text-classification": [],
    "text-to-image": [],
    "text2text-generation": [],
    "zero-shot-image-classification": [],
    "tabular-classification": [],
    "tabular-regression": [],
    "image-to-image": [],
    "tabular-to-text": [],
    "unconditional-image-generation": [],
    "text-retrieval": [],
    "text-to-speech": [],
    "object-detection": [],
    "audio-to-audio": [],
    "text-generation": [],
    "conversational": [],
    "table-question-answering": [],
    "visual-question-answering": [],
    "image-to-text": [],
    "reinforcement-learning": [],
    "voice-activity-detection": [],
    "time-series-forecasting": [],
    "document-question-answering": [],
}


if __name__ == "__main__":
       from argparse import ArgumentParser

       __SCREAMING_SNAKE_CASE    	=ArgumentParser(usage="Validate the yaml metadata block of a README.md file.")
       ap.add_argument("readme_filepath")
       __SCREAMING_SNAKE_CASE    	=ap.parse_args()

       __SCREAMING_SNAKE_CASE    	=Path(args.readme_filepath)
       __SCREAMING_SNAKE_CASE    	=DatasetMetadata.from_readme(readme_filepath)
       print(dataset_metadata)
       dataset_metadata.to_readme(readme_filepath)

