less optimized, but shorted code

use 2 queues to do BFS