




"""simple docstring"""






import sys
from collections import defaultdict




class 	a__      :





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




											"""simple docstring"""







											_lowerCAmelCase:Optional[Any]						=	[]





						def    __UpperCamelCase  (				self   :						int  ,a__   :						List[Any])    ->							Dict:




											"""simple docstring"""







											return self.node_position[vertex]





						def    __UpperCamelCase  (				self   :						Optional[int]  ,a__   :						List[str]  ,a__   :						Optional[Any])    ->							List[Any]:




											"""simple docstring"""







											_lowerCAmelCase:List[str]						=	pos





						def    __UpperCamelCase  (				self   :						int  ,a__   :						int  ,a__   :						int  ,a__   :						Any  ,a__   :						str)    ->							Optional[Any]:




											"""simple docstring"""







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

																					_lowerCAmelCase:Tuple						=	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   :						str  ,a__   :						str  ,a__   :						List[str]  ,a__   :						Any  ,a__   :						Union[str, Any])    ->							int:




											"""simple docstring"""







											_lowerCAmelCase:List[Any]						=	position[index]

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

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





						def    __UpperCamelCase  (				self   :						Optional[int]  ,a__   :						Dict  ,a__   :						Tuple)    ->							List[str]:




											"""simple docstring"""







											_lowerCAmelCase:Any						=	len(a__) // 2 - 1
											for i in range(a__  ,-1  ,-1):
																self.top_to_bottom(a__  ,a__  ,len(a__)  ,a__)







						def    __UpperCamelCase  (				self   :						List[Any]  ,a__   :						List[Any]  ,a__   :						List[Any])    ->							List[str]:




											"""simple docstring"""







											_lowerCAmelCase:Optional[Any]						=	positions[0]
											_lowerCAmelCase:Optional[int]						=	sys.maxsize
											self.top_to_bottom(a__  ,0  ,len(a__)  ,a__)
											return temp





def 				UpperCAmelCase		(		snake_case      :       int     ):
					_lowerCAmelCase:List[Any]						=	Heap()

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

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

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

					for _ in range(1   ,							len(_lowerCamelCase     )     ):
										_lowerCAmelCase:Tuple						=	heap.delete_minimum(_lowerCamelCase   ,							_lowerCamelCase     )
										if visited[vertex] == 0:
															tree_edges.append((nbr_tv[vertex], vertex)     )
															_lowerCAmelCase:Any						=	1
															for neighbor, distance in adjacency_list[vertex]:
																				if (
																				    visited[neighbor] == 0
																				    and distance < distance_tv[heap.get_position(_lowerCamelCase     )]
																				):
																									_lowerCAmelCase:Tuple						=	distance
																									heap.bottom_to_top(
																									    _lowerCamelCase   ,							heap.get_position(_lowerCamelCase     )   ,							_lowerCamelCase   ,							_lowerCamelCase     )
																									_lowerCAmelCase:int						=	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))













'''simple docstring'''






import json
import os
from pathlib import Path

import pytest

from datasets.download.download_config import DownloadConfig
from datasets.download.download_manager import DownloadManager
from datasets.utils.file_utils import hash_url_to_filename


__UpperCamelCase					    =	"http://www.mocksite.com/file1.txt"
__UpperCamelCase					    =	"\"text\": [\"foo\", \"foo\"]"
__UpperCamelCase					    =	"6d8ce9aa78a471c7477201efbeabd3bb01ac2e7d100a6dc024ba1608361f90a8"




class  _A :
		lowercase__:   str				     =   200
		lowercase__:   List[str]				     =   {'''Content-Length''': '''100'''}
		lowercase__:   Union[str, Any]				     =   {}

		def 	lowercase__     (   self					:   Any  ,      **__magic_name__					:   List[Any]			)					->    Dict:


					"""simple docstring"""

					return [bytes(__magic_name__  ,      """utf-8"""			)]







def 					_a						(       *_lowerCamelCase    ,	**_lowerCamelCase ) ->				List[str]:



			"""simple docstring"""


			return MockResponse()







@pytest.mark.parametrize("""urls_type"""    ,	[str, list, dict] )
def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase ) ->				List[str]:



			"""simple docstring"""


			import requests

			monkeypatch.setattr(_lowerCamelCase    ,	"""request"""    ,	_lowerCamelCase )

			__snake_case					:      Union[str, Any]							      =     URL
			if issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      str							      =     url
			elif issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      Dict							      =     [url]
			elif issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      Union[str, Any]							      =     {"""train""": url}
			__snake_case					:      Dict							      =     """dummy"""
			__snake_case					:      List[str]							      =     """downloads"""
			__snake_case					:      List[Any]							      =     tmp_path
			__snake_case					:      List[Any]							      =     DownloadConfig(
			    cache_dir=os.path.join(_lowerCamelCase    ,	_lowerCamelCase )    ,	use_etag=_lowerCamelCase    ,	)
			__snake_case					:      List[str]							      =     DownloadManager(dataset_name=_lowerCamelCase    ,	download_config=_lowerCamelCase )
			__snake_case					:      int							      =     dl_manager.download(_lowerCamelCase )
			__snake_case					:      Tuple							      =     urls
			for downloaded_paths in [downloaded_paths]:
						if isinstance(_lowerCamelCase    ,	_lowerCamelCase ):
									__snake_case					:      Any							      =     [downloaded_paths]
									__snake_case					:      List[Any]							      =     [urls]
						elif isinstance(_lowerCamelCase    ,	_lowerCamelCase ):
									assert "train" in downloaded_paths.keys()
									__snake_case					:      Tuple							      =     downloaded_paths.values()
									__snake_case					:      Optional[int]							      =     urls.values()
						assert downloaded_paths
						for downloaded_path, input_url in zip(_lowerCamelCase    ,	_lowerCamelCase ):
									assert downloaded_path == dl_manager.downloaded_paths[input_url]
									__snake_case					:      List[str]							      =     Path(_lowerCamelCase )
									__snake_case					:      Any							      =     downloaded_path.parts
									assert parts[-1] == HASH
									assert parts[-2] == cache_subdir
									assert downloaded_path.exists()
									__snake_case					:      Union[str, Any]							      =     downloaded_path.read_text()
									assert content == CONTENT
									__snake_case					:      List[str]							      =     downloaded_path.with_suffix(""".json""" )
									assert metadata_downloaded_path.exists()
									__snake_case					:      Union[str, Any]							      =     json.loads(metadata_downloaded_path.read_text() )
									assert metadata_content == {"url": URL, "etag": None}







@pytest.mark.parametrize("""paths_type"""    ,	[str, list, dict] )
def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase    ,	_lowerCamelCase ) ->				List[Any]:



			"""simple docstring"""


			__snake_case					:      Any							      =     str(_lowerCamelCase )
			if issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      Optional[int]							      =     filename
			elif issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      Tuple							      =     [filename]
			elif issubclass(_lowerCamelCase    ,	_lowerCamelCase ):
						__snake_case					:      Dict							      =     {"""train""": filename}
			__snake_case					:      Optional[Any]							      =     """dummy"""
			__snake_case					:      List[Any]							      =     xz_file.parent
			__snake_case					:      int							      =     """extracted"""
			__snake_case					:      Dict							      =     DownloadConfig(
			    cache_dir=_lowerCamelCase    ,	use_etag=_lowerCamelCase    ,	)
			__snake_case					:      List[str]							      =     DownloadManager(dataset_name=_lowerCamelCase    ,	download_config=_lowerCamelCase )
			__snake_case					:      Optional[Any]							      =     dl_manager.extract(_lowerCamelCase )
			__snake_case					:      Union[str, Any]							      =     paths
			for extracted_paths in [extracted_paths]:
						if isinstance(_lowerCamelCase    ,	_lowerCamelCase ):
									__snake_case					:      Dict							      =     [extracted_paths]
									__snake_case					:      int							      =     [paths]
						elif isinstance(_lowerCamelCase    ,	_lowerCamelCase ):
									assert "train" in extracted_paths.keys()
									__snake_case					:      int							      =     extracted_paths.values()
									__snake_case					:      int							      =     paths.values()
						assert extracted_paths
						for extracted_path, input_path in zip(_lowerCamelCase    ,	_lowerCamelCase ):
									assert extracted_path == dl_manager.extracted_paths[input_path]
									__snake_case					:      Any							      =     Path(_lowerCamelCase )
									__snake_case					:      str							      =     extracted_path.parts
									assert parts[-1] == hash_url_to_filename(_lowerCamelCase    ,	etag=_lowerCamelCase )
									assert parts[-2] == extracted_subdir
									assert extracted_path.exists()
									__snake_case					:      Optional[int]							      =     extracted_path.read_text()
									__snake_case					:      str							      =     text_file.read_text()
									assert extracted_file_content == expected_file_content







def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase ) ->				Optional[int]:



			"""simple docstring"""


			assert path.endswith(""".jsonl""" )
			for num_items, line in enumerate(_lowerCamelCase    ,	start=1 ):
						__snake_case					:      Tuple							      =     json.loads(line.decode("""utf-8""" ) )
						assert item.keys() == {"col_1", "col_2", "col_3"}
			assert num_items == 4







@pytest.mark.parametrize("""archive_jsonl"""    ,	["""tar_jsonl_path""", """zip_jsonl_path"""] )
def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase ) ->				Optional[int]:



			"""simple docstring"""


			__snake_case					:      Any							      =     request.getfixturevalue(_lowerCamelCase )
			__snake_case					:      str							      =     DownloadManager()
			for num_jsonl, (path, file) in enumerate(dl_manager.iter_archive(_lowerCamelCase )    ,	start=1 ):
						_test_jsonl(_lowerCamelCase    ,	_lowerCamelCase )
			assert num_jsonl == 2







@pytest.mark.parametrize("""archive_nested_jsonl"""    ,	["""tar_nested_jsonl_path""", """zip_nested_jsonl_path"""] )
def 					_a						(       _lowerCamelCase    ,	_lowerCamelCase ) ->				List[str]:



			"""simple docstring"""


			__snake_case					:      int							      =     request.getfixturevalue(_lowerCamelCase )
			__snake_case					:      List[str]							      =     DownloadManager()
			for num_tar, (path, file) in enumerate(dl_manager.iter_archive(_lowerCamelCase )    ,	start=1 ):
						for num_jsonl, (subpath, subfile) in enumerate(dl_manager.iter_archive(_lowerCamelCase )    ,	start=1 ):
									_test_jsonl(_lowerCamelCase    ,	_lowerCamelCase )
			assert num_tar == 1
			assert num_jsonl == 2







def 					_a						(       _lowerCamelCase ) ->				Any:



			"""simple docstring"""


			__snake_case					:      List[str]							      =     DownloadManager()
			for num_file, file in enumerate(dl_manager.iter_files(_lowerCamelCase )    ,	start=1 ):
						assert os.path.basename(_lowerCamelCase ) == ("test.txt" if num_file == 1 else "train.txt")
			assert num_file == 2


