You want to paint every cell of an grid either white or blue. Some cells are already painted, and their colors cannot be changed.
Paint all remaining cells so that no three consecutive cells in a row and no three consecutive cells in a column all have the same color.
Count the number of distinct ways to paint the grid while satisfying this condition.
The input is given in the following format:
Print the number of valid ways to paint the grid, modulo .
Of the paintings, the two monochromatic paintings are invalid.
The middle cell must be blue.
is a string of length describing the initial state of row . The character . denotes an unpainted cell, W denotes a white cell, and B denotes a blue cell.
., W, and B.| 3 | 25 | , . |
| 4 | 40 | No additional constraints. |