

'''simple docstring'''

class 							_snake_case :
   def __init__( self			:      Optional[Any]							):
     SCREAMING_SNAKE_CASE:Union[str, Any]						      =					0
     SCREAMING_SNAKE_CASE:int						      =					0
     SCREAMING_SNAKE_CASE:Any						      =					{}
   def     __UpperCamelCase						( self			:      List[Any]     ,SCREAMING_SNAKE_CASE__			:      Optional[int]							):







     if vertex not in self.adjacency:
       SCREAMING_SNAKE_CASE:int						      =					{}
       self.num_vertices += 1
   def     __UpperCamelCase						( self			:      Any     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      int     ,SCREAMING_SNAKE_CASE__			:      Any							):
     self.add_vertex(lowerCAmelCase_							)
     self.add_vertex(lowerCAmelCase_							)

     if head == tail:
       return

     SCREAMING_SNAKE_CASE:Any						      =					weight
     SCREAMING_SNAKE_CASE:str						      =					weight
   def     __UpperCamelCase						( self			:      Union[str, Any]							):
     SCREAMING_SNAKE_CASE:Optional[Any]						      =					self.get_edges()
     for edge in edges:
       SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Optional[Any]						      =					edge
       edges.remove((tail, head, weight)							)
     for i in range(len(lowerCAmelCase_							)							):
       SCREAMING_SNAKE_CASE:Optional[int]						      =					list(edges[i]							)

     edges.sort(key=lambda SCREAMING_SNAKE_CASE__							: e[2]							)
     for i in range(len(lowerCAmelCase_							) - 1							):
       if edges[i][2] >= edges[i + 1][2]:
         SCREAMING_SNAKE_CASE:Dict						      =					edges[i][2] + 1
     for edge in edges:
       SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE      ,    SCREAMING_SNAKE_CASE:Tuple						      =					edge
       SCREAMING_SNAKE_CASE:Tuple						      =					weight
       SCREAMING_SNAKE_CASE:List[str]						      =					weight
   def __str__( self			:      List[str]							):
     SCREAMING_SNAKE_CASE:str						      =					""
     for tail in self.adjacency:
       for head in self.adjacency[tail]:
         SCREAMING_SNAKE_CASE:int						      =					self.adjacency[head][tail]
         string += F'''{head} -> {tail} == {weight}\n'''
     return string.rstrip("\n"							)
   def     __UpperCamelCase						( self			:      Optional[Any]							):
     SCREAMING_SNAKE_CASE:List[str]						      =					[]
     for tail in self.adjacency:
       for head in self.adjacency[tail]:
         output.append((tail, head, self.adjacency[head][tail])							)
     return output
   def     __UpperCamelCase						( self			:      Any							):
     return self.adjacency.keys()
   @staticmethod
   def     __UpperCamelCase						( SCREAMING_SNAKE_CASE__			:      Union[str, Any]=None     ,SCREAMING_SNAKE_CASE__			:      Optional[int]=None							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					Graph()
     if vertices is None:
       SCREAMING_SNAKE_CASE:Union[str, Any]						      =					[]
     if edges is None:
       SCREAMING_SNAKE_CASE:Optional[int]						      =					[]
     for vertex in vertices:
       g.add_vertex(lowerCAmelCase_							)
     for edge in edges:
       g.add_edge(*lowerCAmelCase_							)
     return g





   class 							_snake_case :
      def __init__( self			:      str							):
        SCREAMING_SNAKE_CASE:List[str]						      =					{}
        SCREAMING_SNAKE_CASE:int						      =					{}
      def __len__( self			:      List[Any]							):
        return len(self.parent							)
      def     __UpperCamelCase						( self			:      int     ,SCREAMING_SNAKE_CASE__			:      Optional[Any]							):







        if item in self.parent:
          return self.find(lowerCAmelCase_							)

        SCREAMING_SNAKE_CASE:Tuple						      =					item
        SCREAMING_SNAKE_CASE:Any						      =					0
        return item
      def     __UpperCamelCase						( self			:      Optional[Any]     ,SCREAMING_SNAKE_CASE__			:      List[Any]							):







        if item not in self.parent:
          return self.make_set(lowerCAmelCase_							)
        if item != self.parent[item]:
          SCREAMING_SNAKE_CASE:int						      =					self.find(self.parent[item]							)
        return self.parent[item]







      def     __UpperCamelCase						( self			:      List[str]     ,SCREAMING_SNAKE_CASE__			:      str     ,SCREAMING_SNAKE_CASE__			:      Tuple							):
        SCREAMING_SNAKE_CASE:Optional[int]						      =					self.find(lowerCAmelCase_							)
        SCREAMING_SNAKE_CASE:Optional[Any]						      =					self.find(lowerCAmelCase_							)

        if roota == roota:
          return roota

        if self.rank[roota] > self.rank[roota]:
          SCREAMING_SNAKE_CASE:Dict						      =					roota
          return roota

        if self.rank[roota] < self.rank[roota]:
          SCREAMING_SNAKE_CASE:List[str]						      =					roota
          return roota

        if self.rank[roota] == self.rank[roota]:
          self.rank[roota] += 1
          SCREAMING_SNAKE_CASE:Optional[int]						      =					roota
          return roota
        return None



   @staticmethod
   def     __UpperCamelCase						( SCREAMING_SNAKE_CASE__			:      str							):
     SCREAMING_SNAKE_CASE:List[Any]						      =					graph.num_vertices

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

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

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



'''simple docstring'''

def    A_  ( snake_case ):
  SCREAMING_SNAKE_CASE:Dict						      =					(1 + 24 * n) ** 0.5
  return ((1 + root) / 6) % 1 == 0





def    A_  ( snake_case = 5000 ):
  SCREAMING_SNAKE_CASE:int						      =					[(i * (3 * i - 1)) // 2 for i in range(1      ,       snake_case )]
  for i, pentagonal_i in enumerate(snake_case ):
    for j in range(snake_case      ,       len(snake_case ) ):
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_nums[j]
      SCREAMING_SNAKE_CASE:Any						      =					pentagonal_i + pentagonal_j
      SCREAMING_SNAKE_CASE:int						      =					pentagonal_j - pentagonal_i
      if is_pentagonal(snake_case ) and is_pentagonal(snake_case ):
        return b

  return -1


if __name__ == "__main__":
    print(f'''{solution() = }''')






