Input consists of one or more mazes. Each maze begins with a line containing two integers, W and h , denoting the width and the height of the maze. End of input is indicated when either of these values is less than 3.
This is followed by h lines of input. In each of these lines, only the first w characters are significant. If the input line contains fewer than w characters, you should treat the missing characters as `X'.
The interpretation of the characters in these lines is as follows:
- ' ' denotes an open space
- 'G' is an open space representing a goal location - there will be exactly one of these in any maze.
- 'X' denotes a wall
- 'E' is an open space representing an entrance. All entrances will occur on the outer perimeter (as defined by the w and h values) of the maze and no two entrances will be adjacent.
All mazes will be completely enclosed by a combination of 'X' and 'E' characters.