breadth first search solution for maze