Bicolored Matrix

Time limit: 0.2s Memory limit: 64MB Input: Output:

Stefan has become interested in drawing various pictures. In order to enhance his skills, he decided to combine his new passion, drawing, with his older passion, which is computer science.

Therefore, he decided to start with a matrix of size nn and mm, which has on its nmn \cdot m squares either 00, 11 or . After that, he will want to draw the matrix in such a way that for each column, we will start with zeroes and then we will continue with ones.

In other words, we want for each column jj to have the first ii lines completed with 00 and the remaining nin − i lines with 11, by replacing the squares equal to * with either 00 or 11. The squares which are initially completed with 00 and 11 cannot be replaced. The ii doesn't have to be the same for every column.

Now, he wants to find the number of matrices which respect the pattern described previously.

In order to make this challenge more interesting, he will also ask you the answer for two different situations: The first situation is when the number of zeroes on each column doesn't have any restrictions.

The second situation is when the number of zeroes on each column has to be at least equal to the number of zeroes from the previous column, for each column from 22 to mm.

Since this answer can be really big, we want its reminder when dividing by 109+710^9 + 7.

Input

The first line of the input contains cc, the type of requirement which has to be solved (c=1c = 1 or c=2c = 2). The second line of the input contain nn and mm, the size of the grid (1n,m103)(1 ≤ n, m ≤ 10^3).

The next nn lines of the input contain mm characters each, representing the grid (aij=0,1(a_{ij} = 0, 1 or )∗). The characters are not separated by spaces.

Each subproblem is worth 5050 points.

For each of the subproblems, there are tests worth 2020 points, such that (1n,m1001 ≤ n, m ≤ 100) (for a total of 4040 points).

Output

The output contains the answer modulo 109+710^9 + 7.

Examples

stdin

1
4 5
0**0*
*1***
**1**
1****

stdout

360

stdin

2
4 5
0**0*
*1***
**1**
1****

stdout

16

Log in or sign up to be able to send submissions!