Problem: Snuke has a grid with H rows and W columns. The square at the i-th row and j-th column contains a character S_{i,j}.

He can perform the following two kinds of operation on the grid:

* Row-reverse: Reverse the order of the squares in a selected row.
* Column-reverse: Reverse the order of the squares in a selected column.



For example, reversing the 2-nd row followed by reversing the 4-th column will result as follows:

<image>

By performing these operations any number of times in any order, how many placements of characters on the grid can be obtained?

Constraints

* 1≦H,W≦200
* S_{i,j} is a lowercase English letter (`a`-`z`).

Input

The input is given from Standard Input in the following format:


H W
S_{1,1}S_{1,2}...S_{1,W}
S_{2,1}S_{2,2}...S_{2,W}
:
S_{H,1}S_{H,2}...S_{H,W}


Output

Print the number of placements of characters on the grid that can be obtained, modulo 1000000007 (=10^9+7).

Examples

Input

2 2
cf
cf


Output

6


Input

1 12
codefestival


Output

2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long LL;
LL gcd(LL a, LL b){
	if(b == 0) return a;
	return gcd(b,a%b);
}
LL powmod(LL a, LL n){
	if(n == 0) return 1;
	if(n % 2) return (a*powmod(a,n-1)) % MOD;
	LL c = powmod(a,n/2);
	return (c*c) % MOD;
}
LL inv(LL a){
	return powmod(a,MOD-2) % MOD;
}

vector<int> edges[400000];
int vis[400000];
int ncc = 0;
void dfs(int a){
	if(vis[a]) return;
	vis[a] = 1;
	for(int c = 0; c < edges[a].size(); c++) dfs(edges[a][c]);
}
int main(){
	int a, b;
	cin >> a >> b;
	int freq[26];
	string s[a];
	for(int i = 0; i < a; i++) cin >> s[i];
	LL ans = 1;
	LL num24 = 0;
	int aa = a/2;
	int bb = b/2;
	int zz = 0;
	for(int i = 0; i < 400000; i++) vis[i] = 0;
	for(int i = 0; i < a-1-i; i++){
		for(int j = 0; j < b-1-j; j++){
			//cout << i << " " << j << endl;
			for(int z = 0; z < 26; z++) freq[z] = 0;
			freq[s[i][j]-'a']++;
			freq[s[a-1-i][j]-'a']++;
			freq[s[i][b-1-j]-'a']++;
			freq[s[a-1-i][b-1-j]-'a']++;
			LL r = 24;
			for(int z = 0; z < 26; z++){
				if(freq[z] == 4) r /= 24;
				if(freq[z] == 3) r /= 6;
				if(freq[z] == 2) r /= 2;
			}
			if(r == 24){
				edges[i].push_back(aa+j);
				edges[aa+j].push_back(i);
				zz++;
			}
			ans *= r;
			ans %= MOD;
		}
	}

	for(int i = 0; i < aa+bb; i++) vis[i] = 0;
	for(int i = 0; i < aa+bb; i++){
		if(!vis[i]){
			ncc++;
			dfs(i);
		}
	}
	//cout << aa << " " << bb << " " << zz << endl;
	//cout << ncc << endl;
	ans *= powmod(inv(2), zz+ncc-aa-bb);
	if(a % 2){
		int c = (a-1)/2;
		LL ok = 1;
		for(int j = 0; j < b; j++){
			if(s[c][j] != s[c][b-1-j]) ok = 2;
		}
		ans *= ok;
		ans %= MOD;
	}
	if(b % 2){
		int c = (b-1)/2;
		LL ok = 1;
		for(int j = 0; j < a; j++){
			if(s[j][c] != s[a-1-j][c]) ok = 2;
		}
		ans *= ok;
		ans %= MOD;
	}
	cout << ans % MOD << endl;
}