Use BFS by two queues