Use BFS to solve maze problem