


import sys
from collections import defaultdict
class 			SCREAMING_SNAKE_CASE__  :
      def __init__(	self    :	Dict					)		->      Optional[Any]:
             a_ :		Union[str, Any]							=  []
      def 	SCREAMING_SNAKE_CASE							(	self    :	List[str]					,							SCREAMING_SNAKE_CASE__    :	Dict					)		->      List[Any]:
             return self.node_position[vertex]
      def 	SCREAMING_SNAKE_CASE							(	self    :	Tuple					,							SCREAMING_SNAKE_CASE__    :	str					,							SCREAMING_SNAKE_CASE__    :	int					)		->      List[Any]:
             a_ :		Union[str, Any]							=  pos
      def 	SCREAMING_SNAKE_CASE							(	self    :	str					,							SCREAMING_SNAKE_CASE__    :	Any					,							SCREAMING_SNAKE_CASE__    :	Dict					,							SCREAMING_SNAKE_CASE__    :	Optional[Any]					,							SCREAMING_SNAKE_CASE__    :	Any					)		->      Union[str, Any]:
             if start > size // 2 - 1:
                    return
             else:
                    if 2 * start + 2 >= size:
                           a_ :		Optional[int]							=  2 * start + 1
                    else:
                           if heap[2 * start + 1] < heap[2 * start + 2]:
                                  a_ :		List[str]							=  2 * start + 1
                           else:
                                  a_ :		List[Any]							=  2 * start + 2
                    if heap[smallest_child] < heap[start]:
                           a_							,		a_ :		Dict							=  heap[smallest_child], positions[smallest_child]
                           a_							,		a_ :		str							=  (
                               heap[start],
                               positions[start],
                           )
                           a_							,		a_ :		List[str]							=  temp, tempa

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

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

                    if val < heap[parent]:
                           a_ :		str							=  heap[parent]
                           a_ :		int							=  position[parent]
                           self.set_position(position[parent]					,							SCREAMING_SNAKE_CASE__					)
                    else:
                           a_ :		Dict							=  val
                           a_ :		List[Any]							=  temp
                           self.set_position(SCREAMING_SNAKE_CASE__					,							SCREAMING_SNAKE_CASE__					)
                           break
                    a_ :		Optional[Any]							=  parent
             else:
                    a_ :		Dict							=  val
                    a_ :		Union[str, Any]							=  temp
                    self.set_position(SCREAMING_SNAKE_CASE__					,							0					)
      def 	SCREAMING_SNAKE_CASE							(	self    :	Dict					,							SCREAMING_SNAKE_CASE__    :	Tuple					,							SCREAMING_SNAKE_CASE__    :	Dict					)		->      int:
             a_ :		Dict							=  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 	SCREAMING_SNAKE_CASE							(	self    :	Optional[Any]					,							SCREAMING_SNAKE_CASE__    :	Tuple					,							SCREAMING_SNAKE_CASE__    :	Tuple					)		->      str:
             a_ :		List[Any]							=  positions[0]
             a_ :		str							=  sys.maxsize
             self.top_to_bottom(SCREAMING_SNAKE_CASE__					,							0					,							len(SCREAMING_SNAKE_CASE__					)					,							SCREAMING_SNAKE_CASE__					)
             return temp







def 	SCREAMING_SNAKE_CASE_						(      __A			:      int    )     ->		Optional[Any]:

       """simple docstring"""

       a_ :		Dict							=  Heap()

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

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

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

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


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






import json
import sys







def 	SCREAMING_SNAKE_CASE_						(      __A			:      Optional[Any]  ,   __A			:      List[str]    )     ->		Tuple:

       """simple docstring"""

       with open(__A  ,   encoding='utf-8'    ) as f:
              a_ :		Union[str, Any]							=  json.load(__A    )

       a_ :		Any							=  ['<details>', '<summary>Show updated benchmarks!</summary>', ' ']

       for benchmark_name in sorted(__A    ):
              a_ :		List[str]							=  results[benchmark_name]

              a_ :		int							=  benchmark_name.split('/'    )[-1]
              output_md.append(F"""### Benchmark: {benchmark_file_name}"""    )

              a_ :		Any							=  '| metric |'
              a_ :		Optional[Any]							=  '|--------|'
              a_ :		int							=  '| new / old (diff) |'
              for metric_name in sorted(__A    ):
                     a_ :		List[Any]							=  benchmark_res[metric_name]
                     a_ :		int							=  metric_vals['new']
                     a_ :		Union[str, Any]							=  metric_vals.get('old'  ,   __A    )
                     a_ :		Optional[int]							=  metric_vals.get('diff'  ,   __A    )

                     a_ :		str							=  F""" {new_val:f}""" if isinstance(__A  ,   (int, float)    ) else 'None'

                     if old_val is not None:
                            val_str += F""" / {old_val:f}""" if isinstance(__A  ,   (int, float)    ) else "None"
                     if dif_val is not None:
                            val_str += F""" ({dif_val:f})""" if isinstance(__A  ,   (int, float)    ) else "None"

                     title += " " + metric_name + " |"
                     lines += "---|"
                     value += val_str + " |"

              output_md += [title, lines, value, " "]

       output_md.append('</details>'    )

       with open(__A  ,   'w'  ,   encoding='utf-8'    ) as f:
              f.writelines('\n'.join(__A    )    )


if __name__ == "__main__":
   UpperCAmelCase_				:			int   =	sys.argv[1]
   UpperCAmelCase_				:			Any   =	sys.argv[2]

   format_json_to_md(input_json_file, output_md_file)


