from collections import deque

graph={'A':['B','C'],'B':['D','E'],'C':['F','G']}
def bfs(graph,start):
    queue=deque(start)
    visited=[]
    last=''
    while(queue):
        u=queue.popleft()
        last=u
        for v in graph[u]:
            if v not in visited:
                visited.append(v)
   start,last=last,start             
                
                
        
    
    
