The input consists of several instances, separated by single empty lines.
The first line of each instance consists of two integers m and n, 1 m, n 8. Each of m following lines consists of n characters and determines the initial state of the chessboard. The characters are one of the following:
- "." for an empty field of the chessboard
- "#" for a removed field of the chessboard
- "P" for the field of the chessboard where one of the pieces starts
There are always precisely two characters "P" in each instance.