





import heapq as hq
import math
from collections.abc import Iterator



class     _UpperCAmelCase   :

		"""simple docstring"""


		def __init__(    self			:		Union[str, Any] ,  lowerCAmelCase_			:		int					)							->						Optional[int]:
					__lowerCAmelCase							     =     str(id_					)
					__lowerCAmelCase							     =     None
					__lowerCAmelCase							     =     None
					__lowerCAmelCase							     =     []
					__lowerCAmelCase							     =     {}  # {vertex:distance}






		def __lt__(    self			:		Any ,  lowerCAmelCase_			:		Dict					)							->						Optional[Any]:
					return self.key < other.key






		def __repr__(    self			:		Dict					)							->						Optional[int]:
					return self.id






		def     lowercase		(    self			:		List[str] ,  lowerCAmelCase_			:		Optional[Any]					)							->						Tuple:
					self.neighbors.append(__A					)






		def     lowercase		(    self			:		Dict ,  lowerCAmelCase_			:		Union[str, Any] ,  lowerCAmelCase_			:		Optional[Any]					)							->						str:
					__lowerCAmelCase							     =     weight





def   a_   (			lowerCAmelCase_				:      str,     lowerCAmelCase_				:      Dict,     lowerCAmelCase_				:      Any,     lowerCAmelCase_				:      Union[str, Any]     ):
			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],     _lowercase     )
			graph[b - 1].add_edge(graph[a - 1],     _lowercase     )

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

def   a_   (			lowerCAmelCase_				:      int,     lowerCAmelCase_				:      Dict     ):







			for u in graph:
						__lowerCAmelCase							     =     math.inf
						__lowerCAmelCase							     =     None
			__lowerCAmelCase							     =     0

			__lowerCAmelCase							     =     list(_lowercase     )
			hq.heapify(_lowercase     )

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

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

def   a_   (			):
			pass









if __name__ == "__main__":
					import doctest

					doctest.testmod()








from functools import lru_cache

@lru_cache
def   a_   (			lowerCAmelCase_				:      int     ):
   if num < 0:
      raise ValueError('Number should not be negative.'     )

   return 1 if num in (0, 1) else num * factorial(num - 1     )


if __name__ == "__main__":
     import doctest

     doctest.testmod()

