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,a[15],b[15];
char s[15][15];
string ss[15];
void dfs1(int x,bool f)
{
	if(x==w)
	{
		cout<<"YES"<<endl;
		exit(0);
	}
	else if(b[x]!=-1)
	{
		dfs1(x+1,f);
	}
	else
	{
		int i,j;
		for(int i=x+1;i<w;i++)
		{
			if(b[i]!=-1)
			{
				continue;
			}
			for(j=0;j<h;j++)
			{
				if(s[j][x]!=s[a[j]][i])
				{
					break;
				}
			}
			if(j==h)
			{
				b[x]=i;
				b[i]=x;
				dfs1(x+1,f);
				b[x]=b[i]=-1;
			}
		}
		if(!f)
		{
			for(j=0;j<h;j++)
			{
				if(s[j][x]!=s[a[j]][x])
				{
					break;
				}
			}
			if(j==h)
			{
				b[x]=x;
				dfs1(x+1,true);
				b[x]=-1;
			}
		}
	}
}
void dfs2(int x,bool f)
{
	if(x==h)
	{
		dfs1(0,w%2==0);
	}
	else if(a[x]!=-1)
	{
		dfs2(x+1,f);
	}
	else
	{
		int i;
		for(i=x+1;i<h;i++)
		{
			if(a[i]!=-1)
			{
				continue;
			}
			if(ss[x]!=ss[i])
			{
				continue;
			}
			a[x]=i;
			a[i]=x;
			dfs2(x+1,f);
			a[x]=a[i]=-1;
		}
		if(!f)
		{
			a[x]=x;
			dfs2(x+1,true);
			a[x]=-1;
		}
	}
}
int main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			cin>>s[i][j];
		}
	}
	for(int i=0;i<h;i++)
	{
		ss[i]=(string)s[i];
		sort(ss[i].begin(),ss[i].end());
	}
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	dfs2(0,h%2==0);
	cout<<"NO"<<endl;
	return 0;
}