There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.

Snuke can apply the following operation to this grid any number of times:

* Choose two different rows and swap them. Or, choose two different columns and swap them.



Snuke wants this grid to be symmetric. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.

Determine if Snuke can achieve this objective.

Constraints

* 1 \leq H \leq 12
* 1 \leq W \leq 12
* |S_i| = W
* S_i consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:


H W
S_1
S_2
:
S_H


Output

If Snuke can make the grid symmetric, print `YES`; if he cannot, print `NO`.

Examples

Input

2 3
arc
rac


Output

YES


Input

3 7
atcoder
regular
contest


Output

NO


Input

12 12
bimonigaloaf
faurwlkbleht
dexwimqxzxbb
lxdgyoifcxid
ydxiliocfdgx
nfoabgilamoi
ibxbdqmzxxwe
pqirylfrcrnf
wtehfkllbura
yfrnpflcrirq
wvcclwgiubrk
lkbrwgwuiccv


Output

YES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<set>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define fi first
#define se second
#define pr(x) cerr<<#x<<"="<<(x)<<endl
#define pri(x,lo) {cerr<<#x<<"={";for (int ol=0;ol<=lo;ol++)cerr<<x[ol];cerr<<"}"<<endl;}
#define inf 100000000
#define N 1000
int n,m,i,j,vis[N],v[N];
string s[N],a[N],b[N];
pair<int,int> p[N];
char ch[N];
void check()
{
	//pr(666);
	//for (i=0;i<n/2;i++) printf("%d <=> %d\n",p[i].fi,p[i].se);cout<<endl;
	for (i=0;i<n/2;i++) a[i]=s[p[i].fi],a[n-i-1]=s[p[i].se];
	for (i=0;i<n;i++) if (vis[i]==0) a[n/2]=s[i];
	for (i=0;i<m;i++) b[i].clear();
	for (i=0;i<=m;i++) for (j=0;j<n;j++) b[i].pb(a[j][i]);
	
	//for (i=0;i<n;i++) pri(a[i],m);cout<<endl;
	//for (i=0;i<m;i++) pri(b[i],n);
	int f;if (m&1) f=1;else f=0;
	for (i=0;i<m;i++) v[i]=0;
	for (i=0;i<m;i++)
	{
		if (v[i]==0)
		{
			v[i]=1;
			string tmp=b[i];reverse(tmp.begin(),tmp.end());
			int flag=0;
			for (j=0;j<m;j++) if (v[j]==0) if (tmp==b[j]) {flag=1;v[j]=1;break;}
			//pr(i);pr(j);
			if (flag==0)
			{
				if (f==0) return ;
			//	pr(i);
			//	pr(tmp),pr(b[i]);
				if (tmp!=b[i]) return ;
				else f=0;
			}
		}
	}
	printf("YES\n");exit(0);
}
void dfs(int x)
{
	if (x>=n/2+1) {check();return ;}
	int t=0;
	for (int i=n-1;i>=0;i--) if (vis[i]==0) t=i;
	vis[t]=1;
	for (int i=0;i<n;i++) if (vis[i]==0)
	{
		p[x-1]=mp(t,i);
		vis[i]=1;
		dfs(x+1);
		vis[i]=0;
	}
	vis[t]=0;
}
int main()
{
	scanf("%d %d",&n,&m);
	for (i=0;i<n;i++)
	{
		scanf("%s",ch);
		s[i]=ch;
	}
	dfs(1);
	reverse(s,s+n);
	dfs(1);
	random_shuffle(s,s+n);
	dfs(1);
	printf("NO\n");
}
		