#P1539. [TJOI2011] 01矩阵

[TJOI2011] 01矩阵

Description

An n×mn \times m 0101 matrix, in which some positions are already fixed. Positions marked '.' can be filled with 00 or 11. Count the number of matrices for which the difference between any two adjacent positions is 11 (i.e., adjacent cells sharing a side have different values), and output the answer modulo 1000710007.

Input Format

The first line contains two integers n,mn, m.

Then follows an n×mn \times m matrix consisting of 0,1,.\verb!0!,\verb!1!,\verb!.!.

Output Format

Output a single integer: the number of matrices satisfying the condition, modulo 1000710007.

2 3
10.
...

5

Hint

Constraints and Conventions

For 100%100\% of the testdata, n×m225n \times m \le 225.

Translated by ChatGPT 5