An
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.
Constraints
At least one square in the grid will be .
.
Input Specification
The first line contains two space-separated integers
Each of the next R
to represent a red square, B
to represent a blue square, or .
to indicate a square that has not been colored.
Output Specification
Print, on a single line, the number of distinct colorings possible.
Sample Input 1
Copy
3 2
..
B.
.R
Sample Output 1
Copy
6
Sample Input 2
Copy
7 6
......
.....B
.B..R.
......
...B..
.R....
...R..
Sample Output 2
Copy
3
Sample Input 3
Copy
2 2
R.
.B
Sample Output 3
Copy
0
Comments