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>
using namespace std;
int n, m, w[110][110], CX[110], CY[110];
char p[210][210], q[4];
long long res = 1, Mod = 1000000007;
int main() {
	int i, j;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= n; i++) {
		scanf("%s", p[i] + 1);
	}
	if (n % 2 == 1) {
		for (i = 1; i <= m / 2; i++) {
			if (p[n / 2 + 1][i] != p[n / 2 + 1][m + 1 - i]) {
				res = res * 2 % Mod;
				break;
			}
		}
	}
	if (m % 2 == 1) {
		for (i = 1; i <= n / 2; i++) {
			if (p[i][m / 2 + 1] != p[n + 1 - i][m / 2 + 1]) {
				res = res * 2 % Mod;
				break;
			}
		}
	}
	for (i = 1; i <= n / 2; i++) {
		for (j = 1; j <= m / 2; j++) {
			q[0] = p[i][j];
			q[1] = p[n + 1 - i][j];
			q[2] = p[i][m + 1 - j];
			q[3] = p[n + 1 - i][m + 1 - j];
			sort(q, q + 4);
			int s = 0;
			do {
				s++;
			} while (next_permutation(q, q + 4));
			w[i][j] = s;
			if (s == 24) {
				CX[i] = 1, CY[j] = 1;
				res = res * 12 % Mod;
			}
			else res = res*s%Mod;
		}
	}
	int c = 0;
	for (i = 1; i <= 100; i++)c += CX[i] + CY[i];
	if (c > 0)c--;
	for (i = 0; i < c; i++)res = res * 2 % Mod;
	printf("%lld\n", res);
	return 0;
}