
"""simple docstring"""


# Copyright 2021 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from argparse import ArgumentParser

from accelerate.commands.config import get_config_parser
from accelerate.commands.env import env_command_parser
from accelerate.commands.launch import launch_command_parser
from accelerate.commands.test import test_command_parser
from accelerate.commands.tpu import tpu_command_parser






def       _snake_case				(		):
	A						   =   ArgumentParser('Accelerate CLI tool'	,      usage='accelerate <command> [<args>]'	,      allow_abbrev=snake_case__     )
	A						   =   parser.add_subparsers(help='accelerate command helpers'     )

	# Register commands
	get_config_parser(subparsers=snake_case__     )
	env_command_parser(subparsers=snake_case__     )
	launch_command_parser(subparsers=snake_case__     )
	tpu_command_parser(subparsers=snake_case__     )
	test_command_parser(subparsers=snake_case__     )

	# Let's go
	A						   =   parser.parse_args()

	if not hasattr(snake_case__	,      'func'     ):
		parser.print_help()
		exit(1     )

	# Run
	args.func(snake_case__     )


if __name__ == "__main__":
		main()

"""simple docstring"""


import sys
from collections import defaultdict







class 				lowerCAmelCase_				:



						'''simple docstring'''


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


						def 						_SCREAMING_SNAKE_CASE      ( self     :      Union[str, Any]  ,A_     :      int      )     ->   Optional[int]:
							return self.node_position[vertex]


						def 						_SCREAMING_SNAKE_CASE      ( self     :      Union[str, Any]  ,A_     :      List[Any]  ,A_     :      Any      )     ->   List[Any]:
							A						   =   pos


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

									A						   =   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 						_SCREAMING_SNAKE_CASE      ( self     :      str  ,A_     :      Optional[int]  ,A_     :      Dict  ,A_     :      str  ,A_     :      Union[str, Any]      )     ->   Dict:
							A						   =   position[index]

							while index != 0:
								A						   =   int((index - 2) / 2      ) if index % 2 == 0 else int((index - 1) / 2      )

								if val < heap[parent]:
									A						   =   heap[parent]
									A						   =   position[parent]
									self.set_position(position[parent]  ,A_      )
								else:
									A						   =   val
									A						   =   temp
									self.set_position(A_  ,A_      )
									break
								A						   =   parent
							else:
								A						   =   val
								A						   =   temp
								self.set_position(A_  ,0      )


						def 						_SCREAMING_SNAKE_CASE      ( self     :      Any  ,A_     :      Tuple  ,A_     :      Dict      )     ->   Union[str, Any]:
							A						   =   len(A_      ) // 2 - 1
							for i in range(A_  ,-1  ,-1      ):
								self.top_to_bottom(A_  ,A_  ,len(A_      )  ,A_      )




						def 						_SCREAMING_SNAKE_CASE      ( self     :      Union[str, Any]  ,A_     :      Optional[int]  ,A_     :      Dict      )     ->   Union[str, Any]:
							A						   =   positions[0]
							A						   =   sys.maxsize
							self.top_to_bottom(A_  ,0  ,len(A_      )  ,A_      )
							return temp






def       _snake_case				(		snake_case__   :     Dict     ):
	A						   =   Heap()

	A						   =   [0] * len(snake_case__     )
	A						   =   [-1] * len(snake_case__     )  # Neighboring Tree Vertex of selected vertex
	# Minimum Distance of explored vertex with neighboring vertex of partial tree
	# formed in graph
	A						   =   []  # Heap of Distance of vertices from their neighboring vertex
	A						   =   []

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

	A						   =   []
	A						   =   1
	A						   =   sys.maxsize
	for neighbor, distance in adjacency_list[0]:
		A						   =   0
		A						   =   distance
	heap.heapify(snake_case__	,      snake_case__     )

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


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