#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
char s[200][201];
const int MOD = 1000000007;
LL ans = 1;
bool ii[100], jj[100];

void calc(int i, int j) {
	char a = s[        i][        j];
	char b = s[        i][w - 1 - j];
	char c = s[h - 1 - i][        j];
	char d = s[h - 1 - i][w - 1 - j];
	
	int eq = 0;
	if(a == b) { eq++; }
	if(a == c) { eq++; }
	if(a == d) { eq++; }
	if(b == c) { eq++; }
	if(b == d) { eq++; }
	if(c == d) { eq++; }
	
	if(eq == 0) {
		ii[i] = true;
		jj[j] = true;
	}
	
	int map[] = { 12, 12, 6, 4, 0, 0, 1 };
	(ans *= map[eq]) %= MOD;
}

int main() {
	scanf("%d%d", &h, &w);
	inc(i, h) { scanf("%s", s[i]); }
	
	if(h % 2 == 1) {
		bool flag = true;
		inc(i, w / 2) { if(s[h / 2][i] != s[h / 2][w - 1 - i]) { flag = false; break; } }
		if(! flag) { ans *= 2; }
	}
	if(w % 2 == 1) {
		bool flag = true;
		inc(i, h / 2) { if(s[i][w / 2] != s[h - 1 - i][w / 2]) { flag = false; break; } }
		if(! flag) { ans *= 2; }
	}
	
	inc(i, h / 2) {
	inc(j, w / 2) {
		calc(i, j);
	}
	}
	
	bool one = false;
	inc(i, h / 2) { if(ii[i]) { if(one) { (ans *= 2) %= MOD; } else { one = true; } } }
	inc(j, w / 2) { if(jj[j]) { if(one) { (ans *= 2) %= MOD; } else { one = true; } } }
	
	printf("%lld\n", ans);
	
	return 0;
}

### Prompt

In CPP, your task is to solve the following 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

### Response

```cpp
#include <cstdio>
#include <cmath>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int h, w;
char s[200][201];
const int MOD = 1000000007;
LL ans = 1;
bool ii[100], jj[100];

void calc(int i, int j) {
	char a = s[        i][        j];
	char b = s[        i][w - 1 - j];
	char c = s[h - 1 - i][        j];
	char d = s[h - 1 - i][w - 1 - j];
	
	int eq = 0;
	if(a == b) { eq++; }
	if(a == c) { eq++; }
	if(a == d) { eq++; }
	if(b == c) { eq++; }
	if(b == d) { eq++; }
	if(c == d) { eq++; }
	
	if(eq == 0) {
		ii[i] = true;
		jj[j] = true;
	}
	
	int map[] = { 12, 12, 6, 4, 0, 0, 1 };
	(ans *= map[eq]) %= MOD;
}

int main() {
	scanf("%d%d", &h, &w);
	inc(i, h) { scanf("%s", s[i]); }
	
	if(h % 2 == 1) {
		bool flag = true;
		inc(i, w / 2) { if(s[h / 2][i] != s[h / 2][w - 1 - i]) { flag = false; break; } }
		if(! flag) { ans *= 2; }
	}
	if(w % 2 == 1) {
		bool flag = true;
		inc(i, h / 2) { if(s[i][w / 2] != s[h - 1 - i][w / 2]) { flag = false; break; } }
		if(! flag) { ans *= 2; }
	}
	
	inc(i, h / 2) {
	inc(j, w / 2) {
		calc(i, j);
	}
	}
	
	bool one = false;
	inc(i, h / 2) { if(ii[i]) { if(one) { (ans *= 2) %= MOD; } else { one = true; } } }
	inc(j, w / 2) { if(jj[j]) { if(one) { (ans *= 2) %= MOD; } else { one = true; } } }
	
	printf("%lld\n", ans);
	
	return 0;
}

```