Maze traversal with stacks using C++