


'''simple docstring'''






__A :  Union[str, Any]    							=				{
    "A": ["B", "C", "E"],
    "B": ["A", "D", "E"],
    "C": ["A", "F", "G"],
    "D": ["B"],
    "E": ["A", "B", "D"],
    "F": ["C"],
    "G": ["C"],
}







def     UpperCamelCase_      (   A__ :       dict							,   A__ :       Any							,   A__ :       Union[str, Any] ):
  '''simple docstring'''





  lowerCAmelCase_      :				List[str]      =       set()
  # keep track of all the paths to be checked
  lowerCAmelCase_      :				Optional[int]      =       [[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
    lowerCAmelCase_      :				Optional[int]      =       queue.pop(0 )
    # get the last node from the path
    lowerCAmelCase_      :				Dict      =       path[-1]
    if node not in explored:
      lowerCAmelCase_      :				List[Any]      =       graph[node]
      # go through all neighbour nodes, construct a new path and
      # push it into the queue
      for neighbour in neighbours:
        lowerCAmelCase_      :				int      =       list(A__ )
        new_path.append(A__ )
        queue.append(A__ )
        # return path if neighbour is goal
        if neighbour == goal:
          return new_path

            # mark node as explored
      explored.add(A__ )

    # in case there's no path between the 2 nodes
  return []







def     UpperCamelCase_      (   A__ :       dict							,   A__ :       Tuple							,   A__ :       Any ):
  '''simple docstring'''





  if not graph or start not in graph or target not in graph:
    return -1
  if start == target:
    return 0
  lowerCAmelCase_      :				Tuple      =       [start]
  lowerCAmelCase_      :				str      =       set(A__ )
  # Keep tab on distances from `start` node.
  lowerCAmelCase_      :				Optional[int]      =       {start: 0, target: -1}
  while queue:
    lowerCAmelCase_      :				str      =       queue.pop(0 )
    if node == target:
      lowerCAmelCase_      :				Optional[Any]      =       (
          dist[node] if dist[target] == -1 else min(dist[target]							,   dist[node] )
      )
    for adjacent in graph[node]:
      if adjacent not in visited:
        visited.add(A__ )
        queue.append(A__ )
        lowerCAmelCase_      :				Union[str, Any]      =       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'''






from __future__ import annotations







def     UpperCamelCase_      (   A__ :       int | float | str							,   A__ :       int | float | str ):
  '''simple docstring'''





  if nth_term == "":
    return [""]
  lowerCAmelCase_      :				str      =       int(A__ )
  lowerCAmelCase_      :				Tuple      =       int(A__ )
  lowerCAmelCase_      :				list[str]      =       []
  for temp in range(int(A__ ) ):
    series.append(f'1 / {pow(temp + 1							,   int(A__ ) )}' if series else """1""" )
  return series


if __name__ == "__main__":
  import doctest

  doctest.testmod()

  __A :  str    							=				int(input("Enter the last number (nth term) of the P-Series"))
  __A :  Tuple    							=				int(input("Enter the power for  P-Series"))
  print("Formula of P-Series => 1+1/2^p+1/3^p ..... 1/n^p")
  print(p_series(nth_term, power))



