





class     snake_case_		:






 '''simple docstring'''





 def __init__(  self		)	->       List[Any]:
    UpperCAmelCase__						=0
    UpperCAmelCase__						=0
    UpperCAmelCase__						={}

 def  __UpperCAmelCase						(  self,		A_		)	->       List[Any]:
    if vertex not in self.adjacency:
       UpperCAmelCase__						={}
       self.num_vertices += 1

 def  __UpperCAmelCase						(  self,		A_,		A_,		A_		)	->       str:
    self.add_vertex(lowerCAmelCase_		)
    self.add_vertex(lowerCAmelCase_		)

    if head == tail:
       return

    UpperCAmelCase__						=weight
    UpperCAmelCase__						=weight

 def  __UpperCAmelCase						(  self		)	->       int:
    UpperCAmelCase__						=self.get_edges()
    for edge in edges:
       UpperCAmelCase__			,							UpperCAmelCase__			,							UpperCAmelCase__						=edge
       edges.remove((tail, head, weight)		)
    for i in range(len(lowerCAmelCase_		)		):
       UpperCAmelCase__						=list(edges[i]		)

    edges.sort(key=lambda A_		: e[2]		)
    for i in range(len(lowerCAmelCase_		) - 1		):
       if edges[i][2] >= edges[i + 1][2]:
          UpperCAmelCase__						=edges[i][2] + 1
    for edge in edges:
       UpperCAmelCase__			,							UpperCAmelCase__			,							UpperCAmelCase__						=edge
       UpperCAmelCase__						=weight
       UpperCAmelCase__						=weight

 def __str__(  self		)	->       Optional[Any]:
    UpperCAmelCase__						=""
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          UpperCAmelCase__						=self.adjacency[head][tail]
          string += f"""{head} -> {tail} == {weight}\n"""
    return string.rstrip("\n"		)

 def  __UpperCAmelCase						(  self		)	->       Union[str, Any]:
    UpperCAmelCase__						=[]
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          output.append((tail, head, self.adjacency[head][tail])		)
    return output

 def  __UpperCAmelCase						(  self		)	->       Dict:
    return self.adjacency.keys()

 @staticmethod
 def  __UpperCAmelCase						(  A_=None,		A_=None		)	->       Tuple:
    UpperCAmelCase__						=Graph()
    if vertices is None:
       UpperCAmelCase__						=[]
    if edges is None:
       UpperCAmelCase__						=[]
    for vertex in vertices:
       g.add_vertex(lowerCAmelCase_		)
    for edge in edges:
       g.add_edge(*lowerCAmelCase_		)
    return g

 class     snake_case_		:






  '''simple docstring'''





  def __init__(  self		)	->       List[Any]:
     UpperCAmelCase__						={}
     UpperCAmelCase__						={}

  def __len__(  self		)	->       List[str]:
     return len(self.parent		)

  def  __UpperCAmelCase						(  self,		A_		)	->       List[Any]:
     if item in self.parent:
        return self.find(lowerCAmelCase_		)

     UpperCAmelCase__						=item
     UpperCAmelCase__						=0
     return item

  def  __UpperCAmelCase						(  self,		A_		)	->       Optional[Any]:
     if item not in self.parent:
        return self.make_set(lowerCAmelCase_		)
     if item != self.parent[item]:
        UpperCAmelCase__						=self.find(self.parent[item]		)
     return self.parent[item]






  def  __UpperCAmelCase						(  self,		A_,		A_		)	->       Dict:
     UpperCAmelCase__						=self.find(lowerCAmelCase_		)
     UpperCAmelCase__						=self.find(lowerCAmelCase_		)

     if roota == roota:
        return roota

     if self.rank[roota] > self.rank[roota]:
        UpperCAmelCase__						=roota
        return roota

     if self.rank[roota] < self.rank[roota]:
        UpperCAmelCase__						=roota
        return roota

     if self.rank[roota] == self.rank[roota]:
        self.rank[roota] += 1
        UpperCAmelCase__						=roota
        return roota
     return None

 @staticmethod
 def  __UpperCAmelCase						(  A_		)	->       str:
    UpperCAmelCase__						=graph.num_vertices

    UpperCAmelCase__						=Graph.UnionFind()
    UpperCAmelCase__						=[]
    while num_components > 1:
       UpperCAmelCase__						={}
       for vertex in graph.get_vertices():
          UpperCAmelCase__						=-1

       UpperCAmelCase__						=graph.get_edges()
       for edge in edges:
          UpperCAmelCase__			,							UpperCAmelCase__			,							UpperCAmelCase__						=edge
          edges.remove((tail, head, weight)		)
       for edge in edges:
          UpperCAmelCase__			,							UpperCAmelCase__			,							UpperCAmelCase__						=edge
          UpperCAmelCase__						=union_find.find(lowerCAmelCase_		)
          UpperCAmelCase__						=union_find.find(lowerCAmelCase_		)
          if seta != seta:
             if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                UpperCAmelCase__						=[head, tail, weight]

             if cheap_edge[seta] == -1 or cheap_edge[seta][2] > weight:
                UpperCAmelCase__						=[head, tail, weight]
       for vertex in cheap_edge:
          if cheap_edge[vertex] != -1:
             UpperCAmelCase__			,							UpperCAmelCase__			,							UpperCAmelCase__						=cheap_edge[vertex]
             if union_find.find(lowerCAmelCase_		) != union_find.find(lowerCAmelCase_		):
                union_find.union(lowerCAmelCase_,		lowerCAmelCase_		)
                mst_edges.append(cheap_edge[vertex]		)
                UpperCAmelCase__						=num_components - 1
    UpperCAmelCase__						=Graph.build(edges=lowerCAmelCase_		)
    return mst







'''simple docstring'''





import re

from filelock import FileLock


try:
					import nltk

					UpperCAmelCase__  			=				True
except (ImportError, ModuleNotFoundError):
					UpperCAmelCase__  			=				False

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






def 						UpperCAmelCase__(				_SCREAMING_SNAKE_CASE					: str ):






			"""simple docstring"""




			re.sub('<n>','',_SCREAMING_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(_SCREAMING_SNAKE_CASE ) )



