bfs using dict as graph and deque module