An orienteering map is to be given in the following format.
########
#@…G#
##.##@##
#…@…S#
#@…#
########
Calculate the minimum distance from the start(S) to the goal(G) with passing all the checkpoints(@).
Specification
‘.’ means an opened-block that players can pass.
‘#’ means a closed-block that players cannot pass.
It is allowed to move only by one step vertically or horizontally.
1 <= w <= 100, 1 <= h <= 100
The maximum number of checkpoints is 18.
Return -1 if given arguments do not satisfy specifications, or players cannot arrive at the goal from the start by passing all the checkpoints.
The input is to be given in the following format, from the standard input.
W H
Row1
Row2
...
RowH
The first row is to describe the width and the height of the orienteering map, sectioned by a space.
Output
Output into the standard output, and put a return.
And later I also have to print the path.