

"""simple docstring"""





class  _lowerCAmelCase  :







 """simple docstring"""







 def __init__(      self							:      List[str]     ):
    __lowercase								=						0
    __lowercase								=						0
    __lowercase								=						{}


 def  _lowercase			(      self							:      Tuple, UpperCAmelCase__							:      Any     ):
    if vertex not in self.adjacency:
       __lowercase								=						{}
       self.num_vertices += 1


 def  _lowercase			(      self							:      Optional[Any], UpperCAmelCase__							:      Any, UpperCAmelCase__							:      List[str], UpperCAmelCase__							:      Union[str, Any]     ):
    self.add_vertex(UpperCAmelCase__     )
    self.add_vertex(UpperCAmelCase__     )

    if head == tail:
       return

    __lowercase								=						weight
    __lowercase								=						weight


 def  _lowercase			(      self							:      List[str]     ):
    __lowercase								=						self.get_edges()
    for edge in edges:
       __lowercase		,__lowercase		,__lowercase								=						edge
       edges.remove((tail, head, weight)     )
    for i in range(len(UpperCAmelCase__     )     ):
       __lowercase								=						list(edges[i]     )

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


 def __str__(      self							:      Tuple     ):
    __lowercase								=						""
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          __lowercase								=						self.adjacency[head][tail]
          string += F"""{head} -> {tail} == {weight}\n"""
    return string.rstrip("\n"     )


 def  _lowercase			(      self							:      Optional[int]     ):
    __lowercase								=						[]
    for tail in self.adjacency:
       for head in self.adjacency[tail]:
          output.append((tail, head, self.adjacency[head][tail])     )
    return output


 def  _lowercase			(      self							:      List[str]     ):
    return self.adjacency.keys()


 @staticmethod
 def  _lowercase			(      UpperCAmelCase__							:      List[str]=None, UpperCAmelCase__							:      Dict=None     ):
    __lowercase								=						Graph()
    if vertices is None:
       __lowercase								=						[]
    if edges is None:
       __lowercase								=						[]
    for vertex in vertices:
       g.add_vertex(UpperCAmelCase__     )
    for edge in edges:
       g.add_edge(*UpperCAmelCase__     )
    return g




 class  _lowerCAmelCase  :







  """simple docstring"""







  def __init__(      self							:      List[Any]     ):
     __lowercase								=						{}
     __lowercase								=						{}


  def __len__(      self							:      int     ):
     return len(self.parent     )


  def  _lowercase			(      self							:      Optional[Any], UpperCAmelCase__							:      Any     ):
     if item in self.parent:
        return self.find(UpperCAmelCase__     )

     __lowercase								=						item
     __lowercase								=						0
     return item


  def  _lowercase			(      self							:      Optional[int], UpperCAmelCase__							:      int     ):
     if item not in self.parent:
        return self.make_set(UpperCAmelCase__     )
     if item != self.parent[item]:
        __lowercase								=						self.find(self.parent[item]     )
     return self.parent[item]



  def  _lowercase			(      self							:      Optional[Any], UpperCAmelCase__							:      Dict, UpperCAmelCase__							:      Optional[Any]     ):
     __lowercase								=						self.find(UpperCAmelCase__     )
     __lowercase								=						self.find(UpperCAmelCase__     )

     if roota == roota:
        return roota

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

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

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







 @staticmethod
 def  _lowercase			(      UpperCAmelCase__							:      List[str]     ):
    __lowercase								=						graph.num_vertices

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

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

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







"""simple docstring"""





import re

from filelock import FileLock


try:
   import nltk

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

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




def   _A  (  UpperCamelCase_					:	str)     ->						str:
   '''simple docstring'''


   re.sub("<n>",      "",      UpperCamelCase_)  # 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(UpperCamelCase_))




