

'''simple docstring'''







__lowerCamelCase						    =     {
    '''A''': ['''B''', '''C''', '''E'''],
    '''B''': ['''A''', '''D''', '''E'''],
    '''C''': ['''A''', '''F''', '''G'''],
    '''D''': ['''B'''],
    '''E''': ['''A''', '''B''', '''D'''],
    '''F''': ['''C'''],
    '''G''': ['''C'''],
}
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)     ->     list[str]:
       A_		   = set()
       # keep track of all the paths to be checked
       A_		   = [[start]]

       # return path if start is goal
       if start == goal:
              return [start]

       # keeps looping until all possible paths have been checked
       while queue:
              # pop the first path from the queue
              A_		   = queue.pop(0			)
              # get the last node from the path
              A_		   = path[-1]
              if node not in explored:
                     A_		   = graph[node]
                     # go through all neighbour nodes, construct a new path and
                     # push it into the queue
                     for neighbour in neighbours:
                            A_		   = list(UpperCAmelCase__			)
                            new_path.append(UpperCAmelCase__			)
                            queue.append(UpperCAmelCase__			)
                            # return path if neighbour is goal
                            if neighbour == goal:
                                   return new_path

            # mark node as explored
                     explored.add(UpperCAmelCase__			)

    # in case there's no path between the 2 nodes
       return []
def  UpperCAmelCase__      ( UpperCAmelCase__,    UpperCAmelCase__,    UpperCAmelCase__			)     ->     int:
       if not graph or start not in graph or target not in graph:
              return -1
       if start == target:
              return 0
       A_		   = [start]
       A_		   = set(UpperCAmelCase__			)
       # Keep tab on distances from `start` node.
       A_		   = {start: 0, target: -1}
       while queue:
              A_		   = queue.pop(0			)
              if node == target:
                     A_		   = (
                         dist[node] if dist[target] == -1 else min(dist[target],    dist[node]			)
                     )
              for adjacent in graph[node]:
                     if adjacent not in visited:
                            visited.add(UpperCAmelCase__			)
                            queue.append(UpperCAmelCase__			)
                            A_		   = dist[node] + 1
       return dist[target]


if __name__ == "__main__":
      print(bfs_shortest_path(demo_graph, '''G''', '''D'''))  # returns ['G', 'C', 'A', 'B', 'D']
      print(bfs_shortest_path_distance(demo_graph, '''G''', '''D'''))  # returns 4



'''simple docstring'''







def  UpperCAmelCase__      ( UpperCAmelCase__ = 10_00			)     ->     int:
       return sum(2 * a * ((a - 1) // 2) for a in range(3,    n + 1			)			)


if __name__ == "__main__":
      print(solution())
