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>

using namespace std;

typedef long long ll;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007

#define N 210
int n, m;
string a[N];

int ff(string a, string b, string c, string d) {
	multiset<string> u;
	u.insert(a);
	u.insert(b);
	u.insert(c);
	u.insert(d);
	a = *u.begin();
	u.erase(u.begin());
	b = *u.begin();
	u.erase(u.begin());
	c = *u.begin();
	u.erase(u.begin());
	d = *u.begin();
	u.erase(u.begin());
	if (a == b && b == c && c == d) return 1;
	if (a == b && b == c || b == c && c == d) return 4;
	if (a == b && c == d) return 6;
	if (a == b || b == c || c == d) return 12;
	return 12;
}

bool gg(string a, string b, string c, string d) {
	multiset<string> u;
	u.insert(a);
	u.insert(b);
	u.insert(c);
	u.insert(d);
	a = *u.begin();
	u.erase(u.begin());
	b = *u.begin();
	u.erase(u.begin());
	c = *u.begin();
	u.erase(u.begin());
	d = *u.begin();
	u.erase(u.begin());
	if (a != b && b != c && c != d) return true;
	return false;
}

bool b[N], c[N];

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i ++) {
		cin >> a[i];
	}
	ll S = 1;
	for (int i = 0; i*2 < n-1; i ++)
		for (int j = 0; j*2 < m-1; j ++) {
			S = (ll)S*ff(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
			if (gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))) b[i] = c[j] = true;
		}
	/*
	for (int i = 0; i*2 < n-1; i ++) {
		int j = 0;
		S = (ll)S*gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
	}
	for (int j = 1; j*2 < m-1; j ++) {
		int i = 0;
		S = (ll)S*gg(string(1, a[i][j]), string(1, a[n-1-i][j]), string(1, a[n-1-i][m-1-j]), string(1, a[i][m-1-j]))%P;
	}
	*/
	int T = 0;
	for (int i = 0; i*2 < n-1; i ++) if (b[i]) T ++;
	for (int j = 0; j*2 < m-1; j ++) if (c[j]) T ++;
	for (int i = 0; i < T-1; i++) S = (ll)S*2%P;
	if (n&1) {
		bool F = true;
		for (int i = 0; i < m; i++)
			if (a[n/2][i] != a[n/2][m-1-i]) F = false;
		if (!F) S = (ll)S*2%P;
	}
	if (m&1) {
		bool F = true;
		for (int i = 0; i < n; i++)
			if (a[i][m/2] != a[n-1-i][m/2]) F = false;
		if (!F) S = (ll)S*2%P;
	}
	cout << S << endl;
	return 0;
}