advanced bfs search , good problem