'''simple docstring'''

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







class 				_lowercase     :


 '''simple docstring'''






 def __init__(      self   :	List[Any]      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]							)  ->    Union[str, Any]:
  __lowerCAmelCase											=						str(id_							)
  __lowerCAmelCase											=						None
  __lowerCAmelCase											=						None
  __lowerCAmelCase											=						[]
  __lowerCAmelCase											=						{}  # {vertex:distance}
 def __lt__(      self   :	List[Any]      ,       SCREAMING_SNAKE_CASE__   :	List[Any]							)  ->    Union[str, Any]:
  return self.key < other.key
 def __repr__(      self   :	str							)  ->    Tuple:
  return self.id
 def a					(      self   :	Any      ,       SCREAMING_SNAKE_CASE__   :	Union[str, Any]							)  ->    List[str]:
  self.neighbors.append(SCREAMING_SNAKE_CASE__							)





 def a					(      self   :	int      ,       SCREAMING_SNAKE_CASE__   :	int      ,       SCREAMING_SNAKE_CASE__   :	Optional[int]							)  ->    List[Any]:
  __lowerCAmelCase											=						weight







def      UpperCamelCase_						(					snake_case_       :       Optional[Any]						,		snake_case_       :       List[str]						,		snake_case_       :       List[str]						,		snake_case_       :       str      )					->     List[str]:






 '''simple docstring'''

 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]						,		snake_case_      )
 graph[b - 1].add_edge(graph[a - 1]						,		snake_case_      )







def      UpperCamelCase_						(					snake_case_       :       list						,		snake_case_       :       Vertex      )					->     list:






 '''simple docstring'''

 __lowerCAmelCase											=						[]
 for u in graph:
  __lowerCAmelCase											=						math.inf
  __lowerCAmelCase											=						None
 __lowerCAmelCase											=						0
 __lowerCAmelCase											=						graph[:]
 while q:
  __lowerCAmelCase											=						min(snake_case_      )
  q.remove(snake_case_      )
  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(snake_case_      )      ):
  a.append((int(graph[i].id      ) + 1, int(graph[i].pi.id      ) + 1)      )
 return a







def      UpperCamelCase_						(					snake_case_       :       list						,		snake_case_       :       Vertex      )					->     Iterator[tuple]:






 '''simple docstring'''

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

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

 while h:
  __lowerCAmelCase											=						hq.heappop(snake_case_      )
  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(snake_case_      )

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







def      UpperCamelCase_						(					)					->     None:






 '''simple docstring'''



if __name__ == "__main__":
 import doctest

 doctest.testmod()







'''simple docstring'''

import re

from filelock import FileLock


try:
 import nltk

 _A			:      int					      =				True
except (ImportError, ModuleNotFoundError):
 _A			:      Optional[Any]					      =				False

if NLTK_AVAILABLE:
 with FileLock('''.lock''') as lock:
  nltk.download('''punkt''', quiet=True)







def      UpperCamelCase_						(					snake_case_       :       str      )					->     str:






 '''simple docstring'''

 re.sub("""<n>"""						,		""""""						,		snake_case_      )  # remove pegasus newline char
 assert NLTK_AVAILABLE, "nltk must be installed to separate newlines between sentences. (pip install nltk)"
 return "\n".join(nltk.sent_tokenize(snake_case_      )      )






