Problem: 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.



<image>

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

Solution (in JAVA):

Solution:
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Reverse Game
public class Main{
	Scanner sc=new Scanner(System.in);

	int m, n;
	int[][] a;

	void run(){
		n=sc.nextInt();
		m=sc.nextInt();
		a=new int[n][m];
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				a[j][i]=sc.nextInt();
			}
		}
		solve();
	}

	void solve(){
		int N=n*m, M=N/64+1;
		long[][] A=new long[N][M];
		for(int y=0; y<n; y++){
			for(int x=0; x<m; x++){
				int q=y*m+x;
				for(int j=0; j<n; j++){
					for(int i=0; i<m; i++){
						if(i==x||j==y||abs(x-i)==abs(y-j)){
							int p=j*m+i;
							A[q][p>>>6]|=1L<<(p&63);
						}
					}
				}
				if(a[y][x]==1){
					int p=m*n;
					A[q][p>>>6]|=1L<<(p&63);
				}
			}
		}
		int rank=0;
		boolean NG=false;
		for(int j=0; j<N; j++){
			int at=-1;
			for(int i=j; i<N; i++){
				if((A[i][j>>>6]>>>(j&63)&1)==1){
					at=i;
					break;
				}
			}
			if(at==-1){
				continue;
			}
			long[] t=A[j];
			A[j]=A[at];
			A[at]=t;
			for(int k=j+1; k<N; k++){
				if((A[k][j>>>6]>>>(j&63)&1)==1){
					for(int i=0; i<M; i++){
						A[k][i]^=A[j][i];
					}
				}
			}
			rank++;
		}
		for(int j=N-1; j>=0; j--){
			int at=-1;
			for(int i=N-1; i>=0; i--){
				if((A[j][i>>>6]>>>(i&63)&1)==1){
					at=i;
					break;
				}
			}
			if(at==-1){
				NG|=(A[j][m*n/64]>>>(m*n%64)&1)==1;
				continue;
			}
			for(int k=j-1; k>=0; k--){
				if((A[k][at>>>6]>>>(at&63)&1)==1){
					for(int i=0; i<M; i++){
						A[k][i]^=A[j][i];
					}
				}
			}
		}
		println(NG?"0":powMod(2, N-rank, (long)1e9+9)+"");
	}

	long powMod(long x, long k, long mod){
		if(k==0){
			return 1%mod;
		}else if(k%2==0){
			return powMod(x*x%mod, k/2, mod);
		}else{
			return x*powMod(x, k-1, mod)%mod;
		}
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}