bfs two times