An ~m~-by-~n~ grid ~G~ is good if every square is colored either red or blue, and if the square in row ~i~, column ~j~ is blue, then every square in row ~k~, column ~l~ that satisfies ~k \le i~ and ~l \le j~ must also be colored blue.
You are given a grid that is partially colored in. Count the number of ways to color the remaining squares of the grid such that the grid is good.
~1 \le m, n \le 30~
At least one square in the grid will be
The first line contains two space-separated integers ~m~ and ~n~.
Each of the next ~m~ lines contains ~n~ characters representing the grid. Each character is either
to represent a red square,
B to represent a blue square, or
. to indicate a square that has not been colored.
Print, on a single line, the number of distinct colorings possible.
3 2 .. B. .R
7 6 ...... .....B .B..R. ...... ...B.. .R.... ...R..
2 2 R. .B