#D12179. Reverse Game
Reverse Game
Reverse Game
There was a girl who had a hobby of Othello. I enjoy Othello with my family when I have time.
One day, the girl tried to play Othello as usual. However, everyone was so busy that no one played. So I came up with a game that can be played by one person using Othello's board and spinning top.
problem
Othello pieces are arranged so that the top surface is black or white in all the squares of the vertical \ (R \) square and the horizontal \ (C \) square.
Consider repeating the operation of "selecting a certain square and turning over all the pieces in the vertical, horizontal, and diagonal directions" as shown in the figure below. Find the number of operations that make the tops of all the pieces white. However, the following conditions must be met.
- You cannot operate the same square twice
- Do not distinguish the order of operations
- It is possible to continue the operation after the top surface of all the pieces has turned white.
input
The integer \ (R \) and the integer \ (C \) are given on the first line, separated by blanks.
Subsequently, \ (R \) lines are given \ (C \) integer values (0 or 1), respectively. The \ (c \) th integer on the \ (r \) line represents the state of the square (r, c).
1 indicates that the upper surface is black, and 0 indicates that the upper surface is white.
output
If you can make the top surface of all the pieces on the board white, output the remainder of dividing the number of such operations by \ (1000000009 (= 10 ^ 9 + 9) \) on one line.
If you can't make the tops of all the pieces on the board white, print \ (0 \) on one line.
Constraint
- \ (1 \ leq R \ leq 50, 1 \ leq C \ leq 50 \)
Sample input / output
Input 1
13 1 1 1
Output 1
Four
\ (\ {(1,1) \}, \ {(1,2) \}, \ {(1,3) \}, \ {(1,1), (1) , 2), (1,3) \} \).
Input 2
13 1 0 1
Output 2
0
Input 3
twenty four 0 1 0 1 1 0 1 0
Output 3
1
Example
Input
1 3 1 1 1
Output
4
inputFormat
input
The integer \ (R \) and the integer \ (C \) are given on the first line, separated by blanks.
Subsequently, \ (R \) lines are given \ (C \) integer values (0 or 1), respectively. The \ (c \) th integer on the \ (r \) line represents the state of the square (r, c).
1 indicates that the upper surface is black, and 0 indicates that the upper surface is white.
outputFormat
output
If you can make the top surface of all the pieces on the board white, output the remainder of dividing the number of such operations by \ (1000000009 (= 10 ^ 9 + 9) \) on one line.
If you can't make the tops of all the pieces on the board white, print \ (0 \) on one line.
Constraint
- \ (1 \ leq R \ leq 50, 1 \ leq C \ leq 50 \)
Sample input / output
Input 1
13 1 1 1
Output 1
Four
\ (\ {(1,1) \}, \ {(1,2) \}, \ {(1,3) \}, \ {(1,1), (1) , 2), (1,3) \} \).
Input 2
13 1 0 1
Output 2
0
Input 3
twenty four 0 1 0 1 1 0 1 0
Output 3
1
Example
Input
1 3 1 1 1
Output
4
样例
1 3
1 1 1
4