Right Angle Painting

아직 제출이 없습니다시간 제한4초메모리 제한256 MB

문제

Takahashikun likes to paint floors. There is a floor divided into N×NN \times N grid, and some (possibly zero) cells may contain obstacles.

The information about the grid is given as NN strings S_1,,S_NS\_1, \ldots, S\_N. The jj-th character of S_iS\_i represents the cell (i,j)(i, j): '.' and 's' represent an empty cell, and '#' represents a cell with obstacles.

There is excatly one cell with 's'. First, Takahashikun enters the cell with 's' and paints this cell. After that, he makes zero or more steps according to the following rule:

  • In each step, he moves to one of (vertically or horizontally) adjacent cells and paint it.
  • Except for the first step, the direction of movement must be changed by 9090 degrees from the previous step. That is, after he moves horizontally he must move vertically, and vice versa.
  • He must not enter already painted cells.
  • He must not enter cells with obstacles.
  • He must not go out of the grid.

Determine if he can paint all cells without obstacles.

입력

NN
S_1S\_1
S_2S\_2
\vdots
S_NS\_N

출력

Print "POSSIBLE" if he can paint all cells without obstacles. Otherwise print "IMPOSSIBLE".

제한

  • 1N4001 \leq N \leq 400
  • S_i=N|S\_i| = N
  • Each character in S_iS\_i is one of '.', '#', or 's'.
  • There is exactly one cell with 's'.
  • There is at least one cell with '.'.