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 n,m,p[20],v[20];
string s[20];
bool chk()
{
	memset(v,0,sizeof(v));
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(v[i]!=0||v[j]!=0||i==j)continue;
			bool f=1;
			for(int k=0;k<n;k++)
			{
				if(s[p[k]][i]!=s[k][j])
				{
					f=0;
					break;
				}
			}
			if(f)v[i]=v[j]=1;
		}
	}
	int cc=0,t=0;
	for(int i=0;i<m;i++)
	{
		if(!v[i])
		{
			cc++;
			t=i;
		}
	}
	if(!cc)return true;
	if(cc>=2||m&1==0)return false;
	for(int i=0;i<n;i++)
	{
		if(s[p[i]][t]!=s[i][t])return false;
	}
	return true;
}
void dfs(int x,int v)
{
	if(x>=((n+1)>>1))
	{
		if(chk())
		{
			puts("YES");
			exit(0);
		}
		return;
	}
	for(int i=x;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			if(p[i]==-1&&p[j]==-1)
			{
				p[i]=j;p[j]=i;
				dfs(x+1,v);
				p[i]=-1;
				p[j]=-1;
			}
		}
		if(v!=0&&p[i]==-1)
		{
			p[i]=i;
			dfs(x+1,false);
			p[i]=-1;
		}
	}
}
int main()
{
	//freopen("qc.in","r",stdin);
	memset(p,-1,sizeof(p));
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}  
    dfs(0,n&1);
	puts("NO");
    return 0;
}