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<bits/stdc++.h>
using namespace std;
int h,w,v1[20],v2[20];
string s[20],c[20];
bool f;
void dfs2(int x,int r)
{
	if(f) return;
	if(x==w)
	{
		cout<<"YES";
		f=1;return;
	}
	else if(v2[x]!=-1) dfs2(x+1,r);
	else
	{
		for(int i=x+1;i<w;++i)
		{
			if(v2[i]!=-1) continue;
			bool ok=1;
			for(int j=0;j<h;++j)
			 if(s[v1[j]][i]!=s[j][x])
			  {ok=0;break;}
			if(ok)
			{
				v2[i]=x;v2[x]=i;
				dfs2(x+1,r);
				v2[i]=-1;v2[x]=-1;
			}
		}
		if(r)
		{
			bool ok=1;
			for(int j=0;j<h;++j)
			 if(s[v1[j]][x]!=s[j][x])
			  {ok=0;break;}
			if(ok)
			{
				v2[x]=x;
				dfs2(x+1,0);
				v2[x]=-1;
			}
		}
	}
}
void dfs1(int x,int r)
{
	if(x==h) dfs2(0,w%2);
	else if(v1[x]!=-1) dfs1(x+1,r);
	else
	{
		for(int i=x+1;i<h;++i)
		{
			if(v1[i]!=-1) continue;
			if(c[i]!=c[x]) continue;
			v1[i]=x;v1[x]=i;
			dfs1(x+1,r);
			v1[i]=-1;v1[x]=-1;
		}
		if(r)
		{
			v1[x]=x;
			dfs1(x+1,0);
			v1[x]=-1;
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;++i)
	{
		cin>>s[i];c[i]=s[i];
		sort(c[i].begin(),c[i].end());
	}
	memset(v1,-1,sizeof(v1));
	memset(v2,-1,sizeof(v2));
	dfs1(0,h%2);
	if(!f) cout<<"NO";
	return 0;
}