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

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MX = 210;
const ll MOD = 1e9 + 7;

int n, m;
char s[MX][MX];
int en[MX][MX];

int cc0[MX];
int cc1[MX];
int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> s[i];
	ll ans = 1;
	int fl1 = 0;
	int fl2 = 0;
	for (int i = 0; i * 2 < n; ++i)
		for (int j = 0; j * 2 < m; ++j) {
			if (i * 2 == n - 1 && j * 2 == m - 1)
				continue;
			if (i * 2 == n - 1) {
				if (s[i][j] != s[i][m - 1 - j])
					fl1 = 1;
			}
			else if (j * 2 == m - 1) {
				if (s[i][j] != s[n - 1 - i][j])
					fl2 = 1;
			}
			else {
				vector<char> vv;
				vv.push_back(s[i][j]);
				vv.push_back(s[n - 1 - i][j]);
				vv.push_back(s[n - 1 - i][m - 1 - j]);
				vv.push_back(s[i][m - 1 - j]);
				sort(vv.begin(), vv.end());
				if (vv[0] == vv[3]) {
					en[i][j] = 1;
				}
				else if (vv[0] == vv[2] || vv[1] == vv[3]) {
					en[i][j] = 1;
					ans = (ans * 4) % MOD;
				}
				else if (vv[0] == vv[1] && vv[2] == vv[3]) {
					en[i][j] = 1;
					ans = (ans * 6) % MOD;
				}
				else if (vv[0] == vv[1] || vv[1] == vv[2] || vv[2] == vv[3]) {
					en[i][j] = 1;
					ans = (ans * 12) % MOD;
				}
				else {
					ans = (ans * 12) % MOD;
				}
			}
		}
	if (fl1)
		ans = (ans * 2) % MOD;
	if (fl2)
		ans = (ans * 2) % MOD;
	n = n / 2;
	m = m / 2;
	int fl = 1;
	while (fl) {
		fl = 0;
		for (int i = 0; i < n; ++i)
			cc0[i] = 0;
		for (int i = 0; i < m; ++i)
			cc1[i] = 0;
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
				if (!en[i][j])
					++cc0[i], ++cc1[j];
		for (int i = 0; i < n; ++i) {
			if (cc0[i] >= 2)
				continue;
			if (cc0[i] == 1)
				ans = (ans * 2) % MOD;
			fl = 1;
			for (int j = i + 1; j < n; ++j)
				for (int k = 0; k < m; ++k)
					en[j - 1][k] = en[j][k];
			--n;
			break;
		}
		if (fl)
			continue;
		for (int i = 0; i < m; ++i) {
			if (cc1[i] >= 2)
				continue;
			if (cc1[i] == 1)
				ans = (ans * 2) % MOD;
			fl = 1;
			for (int j = i + 1; j < m; ++j)
				for (int k = 0; k < n; ++k)
					en[k][j - 1] = en[k][j];
			--m;
			break;
		}
		if (fl)
			continue;
	}
	if (n > 0 && m > 0) {
		int cc = (n + m - 1);
		for (int j = 0; j < cc; ++j)
			ans = (ans * 2) % MOD;
	}
	cout << ans << "\n";
	return 0;
}