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<stdio.h>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
using namespace std;
char map[200][200];
#define SIZE 1000
class unionfind
{
public:
	int par[SIZE];
	int ran[SIZE];
	int ren[SIZE];
	void init()
	{
		for(int i=0;i<SIZE;i++)
		{
			par[i]=i;
			ran[i]=0;
			ren[i]=1;
		}
	}
	int find(int a)
	{
		if(a==par[a])return a;
		else return par[a]=find(par[a]);
	}
	void unite(int a,int b)
	{
		a=find(a);
		b=find(b);
		if(a==b)return;
		if(ran[a]>ran[b])
		{
			par[b]=a;
			ren[a]+=ren[b];
		}
		else
		{
			par[a]=b;
			ren[b]+=ren[a];
		}
		if(ran[a]==ran[b])ran[b]++;
	}
};
unionfind uf;
typedef long long ll;
ll mod=1000000007;
int main()
{
	int mx,my;
	scanf("%d%d",&mx,&my);
	for(int i=0;i<mx;i++)
	{
		for(int j=0;j<my;j++)
		{
			scanf(" %c",&map[i][j]);
		}
	}
	ll ret=1;
	if(mx%2==1)
	{
		for(int i=0;i<my;i++)
		{
			if(map[mx/2][i]!=map[mx/2][my-1-i])
			{
				ret*=2;
				break;
			}
		}
	}
	if(my%2==1)
	{
		for(int i=0;i<mx;i++)
		{
			if(map[i][my/2]!=map[mx-1-i][my/2])
			{
				ret*=2;
				break;
			}
		}
	}
	uf.init();
	for(int i=0;i<mx/2;i++)
	{
		for(int j=0;j<my/2;j++)
		{
			vector<char>v;
			v.push_back(map[i][j]);
			v.push_back(map[mx-1-i][j]);
			v.push_back(map[i][my-1-j]);
			v.push_back(map[mx-1-i][my-1-j]);
			sort(v.begin(),v.end());
			int r=0;
			for(;;)
			{
				r++;
				if(!next_permutation(v.begin(),v.end()))break;
			}
			if(r==24)
			{
				if(uf.find(i)!=uf.find(j+200))
				{
					uf.unite(i,j+200);
				}
				else r/=2;
			}
			ret*=r;
			ret%=mod;
		}
	}
	printf("%lld\n",ret);
}