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 <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int H, W;
vector<string> S;

bool pal[110][110];
int cnt[110][110];

int fact[] = { 1, 1, 2, 6, 24 };

int uf[303030];

int root(int p)
{
	return uf[p] < 0 ? p : (uf[p] = root(uf[p]));
}
bool join(int p, int q)
{
	p = root(p);
	q = root(q);
	if (p == q) return false;
	uf[p] += uf[q];
	uf[q] = p;
	return true;
}

int pohe(vector<char> ch)
{
	int ret = 24;
	for (int i = 0; i < ch.size(); ++i) {
		int app = 0;
		for (int j = 0; j < ch.size(); ++j) {
			if (ch[i] == ch[j]) {
				++app;
				if (i < j) goto nxt;
			}
		}
		ret /= fact[app];
	nxt:
		continue;
	}
	return ret;
}

int main()
{
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; ++i) {
		char in[220];
		scanf("%s", in);
		S.push_back(string(in));
	}
	i64 mult = 1;
	if (S.size() % 2 == 1) {
		string tg = S[S.size() / 2];
		string tg2 = tg;
		reverse(tg2.begin(), tg2.end());
		if (tg != tg2) mult *= 2;
		S.erase(S.begin() + (S.size() / 2));
	}
	if (S.size() == 0) {
		printf("%lld\n", mult);
		return 0;
	}
	H = S.size();
	if (S[0].size() % 2 == 1) {
		string tg;
		for (int i = 0; i < H; ++i) {
			tg.push_back(S[i][S[0].size() / 2]);
			S[i].erase(S[i].begin() + (S[0].size() / 2));
		}
		string tg2 = tg;
		reverse(tg2.begin(), tg2.end());
		if (tg != tg2) mult *= 2;
	}
	if (S[0].size() == 0) {
		printf("%lld\n", mult);
		return 0;
	}
	H = S.size();
	W = S[0].size();
	i64 ret = 1;
	for (int i = 0; i < H / 2; ++i) {
		for (int j = 0; j < W / 2; ++j) {
			vector<char> ch;
			ch.push_back(S[i][j]);
			ch.push_back(S[H - 1 - i][j]);
			ch.push_back(S[i][W - 1 - j]);
			ch.push_back(S[H - 1 - i][W - 1 - j]);

			int waf = pohe(ch);
			if (waf == 24) {
				pal[i][j] = true;
				cnt[i][j] = 12;
			} else {
				pal[i][j] = false;
				cnt[i][j] = waf;
			}
		}
	}
	for (int i = 0; i < 5000; ++i) uf[i] = -1;
	int rem = 0;
	for (int i = 0; i < H / 2; ++i) {
		for (int j = 0; j < W / 2; ++j) {
			if (pal[i][j]) {
				if (join(i, j + H / 2)) ++rem;
			}
			ret = ret * cnt[i][j] % MOD;
		}
	}
	while (rem--) ret = ret * 2 % MOD;
	ret = ret * mult % MOD;
	printf("%lld\n", ret);

	return 0;
}