bfs and hash