Works with non-square mazes