





import os

import pytest
import yaml

from datasets.features.features import Features, Value
from datasets.info import DatasetInfo, DatasetInfosDict







@pytest.mark.parametrize(
    "files"			,   [
        ["full:README.md", "dataset_infos.json"],
        ["empty:README.md", "dataset_infos.json"],
        ["dataset_infos.json"],
        ["full:README.md"],
    ]			,   )
def       UpperCAmelCase							(     _lowerCamelCase      :  str			,   _lowerCamelCase      :  Optional[int]     ):





      '''simple docstring'''


      SCREAMING_SNAKE_CASE__     :				str   =					tmp_path_factory.mktemp("dset_infos_dir"     )
      if "full:README.md" in files:
            with open(dataset_infos_dir / "README.md"			,   "w"     ) as f:
                  f.write("---\ndataset_info:\n  dataset_size: 42\n---"     )
      if "empty:README.md" in files:
            with open(dataset_infos_dir / "README.md"			,   "w"     ) as f:
                  f.write(""     )
    # we want to support dataset_infos.json for backward compatibility
      if "dataset_infos.json" in files:
            with open(dataset_infos_dir / "dataset_infos.json"			,   "w"     ) as f:
                  f.write("{\"default\": {\"dataset_size\": 42}}"     )
      SCREAMING_SNAKE_CASE__     :				Any   =					DatasetInfosDict.from_directory(_lowerCamelCase     )
      assert dataset_infos
      assert dataset_infos["default"].dataset_size == 42







@pytest.mark.parametrize(
    "dataset_info"			,   [
        DatasetInfo(),
        DatasetInfo(
            description="foo"			,   features=Features({"a": Value("int32"     )}     )			,   builder_name="builder"			,   config_name="config"			,   version="1.0.0"			,   splits=[{"name": "train"}]			,   download_size=42			,   ),
    ]			,   )
def       UpperCAmelCase							(     _lowerCamelCase      :  str			,   _lowerCamelCase      :  DatasetInfo     ):





      '''simple docstring'''


      SCREAMING_SNAKE_CASE__     :				Tuple   =					str(_lowerCamelCase     )
      dataset_info.write_to_directory(_lowerCamelCase     )
      SCREAMING_SNAKE_CASE__     :				int   =					DatasetInfo.from_directory(_lowerCamelCase     )
      assert dataset_info == reloaded
      assert os.path.exists(os.path.join(_lowerCamelCase			,   "dataset_info.json"     )     )







def       UpperCAmelCase							(     ):





      '''simple docstring'''


      SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					DatasetInfo(
          description="foo"			,   citation="bar"			,   homepage="https://foo.bar"			,   license="CC0"			,   features=Features({"a": Value("int32"     )}     )			,   post_processed={}			,   supervised_keys=()			,   task_templates=[]			,   builder_name="builder"			,   config_name="config"			,   version="1.0.0"			,   splits=[{"name": "train", "num_examples": 42}]			,   download_checksums={}			,   download_size=1_337			,   post_processing_size=442			,   dataset_size=1_234			,   size_in_bytes=1_337 + 442 + 1_234			,   )
      SCREAMING_SNAKE_CASE__     :				Any   =					dataset_info._to_yaml_dict()
      assert sorted(_lowerCamelCase     ) == sorted(DatasetInfo._INCLUDED_INFO_IN_YAML     )
      for key in DatasetInfo._INCLUDED_INFO_IN_YAML:
            assert key in dataset_info_yaml_dict
            assert isinstance(dataset_info_yaml_dict[key]			,   (list, dict, int, str)     )
      SCREAMING_SNAKE_CASE__     :				str   =					yaml.safe_dump(_lowerCamelCase     )
      SCREAMING_SNAKE_CASE__     :				Optional[int]   =					yaml.safe_load(_lowerCamelCase     )
      assert dataset_info_yaml_dict == reloaded







def       UpperCAmelCase							(     ):





      '''simple docstring'''


      SCREAMING_SNAKE_CASE__     :				Optional[Any]   =					DatasetInfo()
      SCREAMING_SNAKE_CASE__     :				str   =					dataset_info._to_yaml_dict()
      assert dataset_info_yaml_dict == {}







@pytest.mark.parametrize(
    "dataset_infos_dict"			,   [
        DatasetInfosDict(),
        DatasetInfosDict({"default": DatasetInfo()}     ),
        DatasetInfosDict({"my_config_name": DatasetInfo()}     ),
        DatasetInfosDict(
            {
                "default": DatasetInfo(
                    description="foo"			,   features=Features({"a": Value("int32"     )}     )			,   builder_name="builder"			,   config_name="config"			,   version="1.0.0"			,   splits=[{"name": "train"}]			,   download_size=42			,   )
            }     ),
        DatasetInfosDict(
            {
                "v1": DatasetInfo(dataset_size=42     ),
                "v2": DatasetInfo(dataset_size=1_337     ),
            }     ),
    ]			,   )
def       UpperCAmelCase							(     _lowerCamelCase      :  Tuple			,   _lowerCamelCase      :  DatasetInfosDict     ):





      '''simple docstring'''


      SCREAMING_SNAKE_CASE__     :				Union[str, Any]   =					str(_lowerCamelCase     )
      dataset_infos_dict.write_to_directory(_lowerCamelCase     )
      SCREAMING_SNAKE_CASE__     :				int   =					DatasetInfosDict.from_directory(_lowerCamelCase     )

      # the config_name of the dataset_infos_dict take over the attribute
      for config_name, dataset_info in dataset_infos_dict.items():
            SCREAMING_SNAKE_CASE__     :				str   =					config_name
            # the yaml representation doesn't include fields like description or citation
            # so we just test that we can recover what we can from the yaml
            SCREAMING_SNAKE_CASE__     :				int   =					DatasetInfo._from_yaml_dict(dataset_info._to_yaml_dict()     )
      assert dataset_infos_dict == reloaded

      if dataset_infos_dict:
            assert os.path.exists(os.path.join(_lowerCamelCase			,   "README.md"     )     )






import sys
from collections import defaultdict



class    _a     :






							"""simple docstring"""

							def __init__(      self				:     Any    )	->Dict:
													SCREAMING_SNAKE_CASE__     :				Tuple   =					[]

							def      A_  (      self				:     int							,	a				:     List[str]    )	->Dict:
													return self.node_position[vertex]

							def      A_  (      self				:     Optional[Any]							,	a				:     Any							,	a				:     List[str]    )	->Optional[Any]:
													SCREAMING_SNAKE_CASE__     :				str   =					pos

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

																									SCREAMING_SNAKE_CASE__     :				Optional[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      A_  (      self				:     Union[str, Any]							,	a				:     Tuple							,	a				:     Tuple							,	a				:     Union[str, Any]							,	a				:     List[Any]    )	->Optional[int]:
													SCREAMING_SNAKE_CASE__     :				List[Any]   =					position[index]

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

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

							def      A_  (      self				:     Union[str, Any]							,	a				:     int							,	a				:     List[str]    )	->Union[str, Any]:
													SCREAMING_SNAKE_CASE__     :				List[str]   =					len(a    ) // 2 - 1
													for i in range(a							,	-1							,	-1    ):
																			self.top_to_bottom(a							,	a							,	len(a    )							,	a    )






							def      A_  (      self				:     Dict							,	a				:     List[Any]							,	a				:     Dict    )	->Optional[int]:
													SCREAMING_SNAKE_CASE__     :				Any   =					positions[0]
													SCREAMING_SNAKE_CASE__     :				Optional[int]   =					sys.maxsize
													self.top_to_bottom(a							,	0							,	len(a    )							,	a    )
													return temp







def       UpperCAmelCase							(     _lowerCamelCase      :  str     ):





						'''simple docstring'''


						SCREAMING_SNAKE_CASE__     :				Optional[int]   =					Heap()

						SCREAMING_SNAKE_CASE__     :				Any   =					[0] * len(_lowerCamelCase     )
						SCREAMING_SNAKE_CASE__     :				Any   =					[-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__     :				Union[str, Any]   =					[]  # Heap of Distance of vertices from their neighboring vertex
						SCREAMING_SNAKE_CASE__     :				str   =					[]

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

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

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


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