시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
4 초 256 MB 1 1 1 100.000%

문제

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

The information about the grid is given as $N$ strings $S_1, \ldots, S_N$. The $j$-th character of $S_i$ represents the cell $(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 $90$ 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.

입력

$N$
$S_1$
$S_2$
$\vdots$
$S_N$

출력

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

제한

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

예제 입력 1

5
#....
..s..
..#..
#....
##..#

예제 출력 1

POSSIBLE

예제 입력 2

5
s.###
..###
###..
#....
#..##

예제 출력 2

IMPOSSIBLE