1506: CF845 - F. Guards In The Storehouse
[Creator : ]
Description
Polycarp owns a shop in the capital of Berland. Recently the criminal activity in the capital increased, so Polycarp is thinking about establishing some better security in the storehouse of his shop.
The storehouse can be represented as a matrix withnrows andmcolumns. Each element of the matrix is either
Polycarp wants to hire some guards (possibly zero) to watch for the storehouse. Each guard will be in some cell of matrix and will protect every cell to the right of his own cell and every cell to the bottom of his own cell, until the nearest wall. More formally, if the guard is standing in the cell $(x_0,y_0)$, then he protects cell $(x_1,y_1)$ if all these conditions are met:
Polycarp wants to know the number of suitable plans. Since it can be very large, you have to output it modulo $10^9+7$.
.
(an empty space) or x
(a wall). Polycarp wants to hire some guards (possibly zero) to watch for the storehouse. Each guard will be in some cell of matrix and will protect every cell to the right of his own cell and every cell to the bottom of his own cell, until the nearest wall. More formally, if the guard is standing in the cell $(x_0,y_0)$, then he protects cell $(x_1,y_1)$ if all these conditions are met:
- $(x_1,y_1)$ is an empty cell;
- either $x_0=x_1$ andy $0≤y_1$, or $x_0≤x_1$ andy $0=y_1$;
- there are no walls between cells $(x_0,y_0)$ and $(x_1,y_1)$.There can be a guard between these cells, guards can look through each other.
Polycarp wants to know the number of suitable plans. Since it can be very large, you have to output it modulo $10^9+7$.
Input
The first line contains two numbers $n, m$ − the length and the width of the storehouse $(1≤n,m≤250,\ 1≤nm≤250)$.
Then $n$ lines follow, $i$th line contains a string consisting of $m$ characters − $i$th row of the matrix representing the storehouse. Each character is either
Then $n$ lines follow, $i$th line contains a string consisting of $m$ characters − $i$th row of the matrix representing the storehouse. Each character is either
.
or x
.
Output
Output the number of suitable plans modulo $10^9+7$.
Sample 1 Input
1 3
.x.
Sample 1 Output
3
you have to put at least one guard, so there are three possible arrangements: one guard in the cell (1,1), one guard in the cell (1,3), and two guards in both these cells.
Sample 2 Input
2 2
xx
xx
Sample 2 Output
1
Sample 3 Input
2 2
..
..
Sample 3 Output
10
3 1
x
.
x
2