#D3007. Connect
Connect
Connect
A grid of r × c is given. Numbers from 1 to 8 are written on some squares on the grid.
It is necessary to connect the squares with numbers and the squares with other numbers with a line. For the squares with numbers written on them, it is necessary to connect lines with other squares as many as the number written on that square. However, the lines can be connected only in the vertical and horizontal directions, and up to two lines can be connected in one direction.
It cannot be connected by a line across other numbers.
In addition, it is not possible to tie them so that they intersect as follows.
Since the grid is given as input, please count how many ways there are ways to correctly connect all the squares with numbers.
Input
The input is given in the following format.
r c grid1 .. .. .. gridr-1
gridi is a string of length c, consisting of numbers from 1 to 8 or ".".
Input meets the following constraints 1 ≤ r, c ≤ 10
Output
Divide the answer value by 100,000,007 and output the remainder on one line
Examples
Input
3 3 .1. 1.1 .1.
Output
0
Input
1 3 1.1
Output
1
Input
3 3 4.2 ... 2..
Output
1
Input
7 7 2.3.1.1 ....... 2...... ....... ..3.3.. ....... 2.2.4.3
Output
10
inputFormat
input, please count how many ways there are ways to correctly connect all the squares with numbers.
Input
The input is given in the following format.
r c grid1 .. .. .. gridr-1
gridi is a string of length c, consisting of numbers from 1 to 8 or ".".
Input meets the following constraints 1 ≤ r, c ≤ 10
outputFormat
Output
Divide the answer value by 100,000,007 and output the remainder on one line
Examples
Input
3 3 .1. 1.1 .1.
Output
0
Input
1 3 1.1
Output
1
Input
3 3 4.2 ... 2..
Output
1
Input
7 7 2.3.1.1 ....... 2...... ....... ..3.3.. ....... 2.2.4.3
Output
10
样例
7 7
2.3.1.1
.......
2......
.......
..3.3..
.......
2.2.4.3
10