





"""simple docstring"""



a_					=     {
    """A""": ["""B""", """C""", """E"""],
    """B""": ["""A""", """D""", """E"""],
    """C""": ["""A""", """F""", """G"""],
    """D""": ["""B"""],
    """E""": ["""A""", """B""", """D"""],
    """F""": ["""C"""],
    """G""": ["""C"""],
}







def 						__lowercase	(  snake_case_    :    dict							,snake_case_    :    Dict							,snake_case_    :    Any		)  ->list[str]:



    '''simple docstring'''







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

            # mark node as explored
            explored.add(snake_case_		)

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







def 						__lowercase	(  snake_case_    :    dict							,snake_case_    :    Optional[Any]							,snake_case_    :    Optional[Any]		)  ->int:



    '''simple docstring'''







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



    '''simple docstring'''







    for i in range(len(snake_case_		) - 1							,0							,-1		):
        __A       :		Union[str, Any]							=	False

        for j in range(snake_case_							,0							,-1		):
            if unsorted[j] < unsorted[j - 1]:
                __A					,			__A       :		Union[str, Any]							=	unsorted[j - 1], unsorted[j]
                __A       :		Optional[int]							=	True

        for j in range(snake_case_		):
            if unsorted[j] > unsorted[j + 1]:
                __A					,			__A       :		Optional[Any]							=	unsorted[j + 1], unsorted[j]
                __A       :		Union[str, Any]							=	True

        if not swapped:
            break
    return unsorted


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       a_					=     input("""Enter numbers separated by a comma:\n""").strip()
       a_					=     [int(item) for item in user_input.split(""",""")]
       print(f'''{cocktail_shaker_sort(unsorted) = }''')




