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 and , which has on its squares either , 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 to have the first lines completed with and the remaining lines with , by replacing the squares equal to with either or . The squares which are initially completed with and cannot be replaced. The 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 to .
Since this answer can be really big, we want its reminder when dividing by .
Input
The first line of the input contains , the type of requirement which has to be solved ( or ). The second line of the input contain and , the size of the grid .
The next lines of the input contain characters each, representing the grid or . The characters are not separated by spaces.
Each subproblem is worth points.
For each of the subproblems, there are tests worth points, such that () (for a total of points).
Output
The output contains the answer modulo .
Examples
stdin
1
4 5
0**0*
*1***
**1**
1****
stdout
360
stdin
2
4 5
0**0*
*1***
**1**
1****
stdout
16