#abc243h. [abc243_h]Builder Takahashi (Enhanced version)

[abc243_h]Builder Takahashi (Enhanced version)

Problem Statement

There is a grid with HtimesWH \\times W squares. Let (i,j)(i,j) denote the square at the ii-th row from the top and jj-th column from the left.
Ci,jC_{i,j} represents the state of each square. Each square is in one of the following four states.

  • S: The starting point. The grid has exactly one starting point.
  • G: The goal. The grid has exactly one goal.
  • .: A constructible square, where a wall can be built.
  • O: An unconstructible square, where a wall cannot be built.

Aoki intends to start at the starting point and get to the goal. When he is at (i,j)(i,j), he can go to (i+1,j)(i+1,j), (i,j+1)(i,j+1), (i1,j)(i-1,j), or (i,j1)(i,j-1). It is not allowed to exit the grid or enter a square with a wall.

Takahashi decides to build a wall on one or more constructible squares of his choice before Aoki starts so that there is no way for Aoki to reach the goal. Here, the starting point and the goal cannot be chosen.

Is it possible for Takahashi to build walls to prevent Aoki from reaching the goal? If it is possible, also compute the two values below:

  • the minimum number nn of walls needed to prevent Aoki from reaching the goal, and
  • the number of ways modulo 998244353998244353, rr, to achieve that minimum number of walls.

Constraints

  • 2leqHleq1002 \\leq H \\leq 100
  • 2leqWleq1002 \\leq W \\leq 100
  • Ci,jC_{i,j} is S, G, ., or O.
  • Each of S and G appears exactly once in Ci,jC_{i,j}.

Input

Input is given from Standard Input in the following format:

HH WW C1,1C_{1,1}C1,2C_{1,2}dots\\dotsC1,WC_{1,W} C2,1C_{2,1}C2,2C_{2,2}dots\\dotsC2,WC_{2,W} vdots\\vdots CH,1C_{H,1}CH,2C_{H,2}dots\\dotsCH,WC_{H,W}

Output

If it is possible to build walls to prevent Aoki from reaching the goal, print the string Yes and the integers nn and rr defined in the Problem Statement, in the following format:

Yes nn rr

Otherwise, print No.


Sample Input 1

4 3
S..
O..
..O
..G

Sample Output 1

Yes
3 6

Let # represent a square to build a wall on. The six ways to achieve the minimum number of walls are as follows:

S#.  S.#  S..  S..  S..  S..
O#.  O#.  O##  O.#  O.#  O.#
#.O  #.O  #.O  ##O  .#O  .#O
..G  ..G  ..G  ..G  #.G  .#G

Sample Input 2

3 2
.G
.O
.S

Sample Output 2

No

Regardless of how Takahashi builds walls, Aoki can always reach the goal.


Sample Input 3

2 2
S.
.G

Sample Output 3

Yes
2 1

Sample Input 4

10 10
OOO...OOO.
.....OOO.O
OOO.OO.OOO
OOO..O..S.
....O.O.O.
.OO.O.OOOO
..OOOG.O.O
.O.O..OOOO
.O.O.OO...
...O..O..O

Sample Output 4

Yes
10 12