



import heapq as hq
import math
from collections.abc import Iterator
class 			_snake_case     :




				def __init__(  self   :  int,   __lowercase   :  Dict  ):
							lowercase__   					=			str(id_  )
							lowercase__   					=			None
							lowercase__   					=			None
							lowercase__   					=			[]
							lowercase__   					=			{}  # {vertex:distance}




				def __lt__(  self   :  Optional[int],   __lowercase   :  int  ):
							return self.key < other.key




				def __repr__(  self   :  Dict  ):
							return self.id




				def 							A__ (  self   :  Tuple,   __lowercase   :  Optional[Any]  ):
							self.neighbors.append(__lowercase  )




				def 							A__ (  self   :  List[Any],   __lowercase   :  Optional[Any],   __lowercase   :  Dict  ):
							lowercase__   					=			weight



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					):
			# add the neighbors:
			graph[a - 1].add_neighbor(graph[b - 1]					)
			graph[b - 1].add_neighbor(graph[a - 1]					)
			# add the edges:
			graph[a - 1].add_edge(graph[b - 1]  ,					SCREAMING_SNAKE_CASE_					)
			graph[b - 1].add_edge(graph[a - 1]  ,					SCREAMING_SNAKE_CASE_					)



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					):
			lowercase__   					=			[]
			for u in graph:
						lowercase__   					=			math.inf
						lowercase__   					=			None
			lowercase__   					=			0
			lowercase__   					=			graph[:]
			while q:
						lowercase__   					=			min(SCREAMING_SNAKE_CASE_					)
						q.remove(SCREAMING_SNAKE_CASE_					)
						for v in u.neighbors:
									if (v in q) and (u.edges[v.id] < v.key):
												lowercase__   					=			u
												lowercase__   					=			u.edges[v.id]
			for i in range(1  ,					len(SCREAMING_SNAKE_CASE_					)					):
						a.append((int(graph[i].id					) + 1, int(graph[i].pi.id					) + 1)					)
			return a



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_  ,					SCREAMING_SNAKE_CASE_					):
			for u in graph:
						lowercase__   					=			math.inf
						lowercase__   					=			None
			lowercase__   					=			0

			lowercase__   					=			list(SCREAMING_SNAKE_CASE_					)
			hq.heapify(SCREAMING_SNAKE_CASE_					)

			while h:
						lowercase__   					=			hq.heappop(SCREAMING_SNAKE_CASE_					)
						for v in u.neighbors:
									if (v in h) and (u.edges[v.id] < v.key):
												lowercase__   					=			u
												lowercase__   					=			u.edges[v.id]
												hq.heapify(SCREAMING_SNAKE_CASE_					)

			for i in range(1  ,					len(SCREAMING_SNAKE_CASE_					)					):
						yield (int(graph[i].id					) + 1, int(graph[i].pi.id					) + 1)



def __lowerCAmelCase	(       ):
			pass


if __name__ == "__main__":
							import doctest

							doctest.testmod()









from __future__ import annotations



def __lowerCAmelCase	(       SCREAMING_SNAKE_CASE_					):
			return len(set(SCREAMING_SNAKE_CASE_					)					) == len(SCREAMING_SNAKE_CASE_					)


if __name__ == "__main__":
							import doctest

							doctest.testmod()




