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
// author: lkx
// Problem:
// ID:
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define MP make_pair
#define PH push
#define ll long long

const int MOD=1e9+7;

int n,m;
char s[22][22],c[22];
string f[22];
int fuck[22][22],fuck2[22][22];
int g[22][22];
int a[22];

bool dfs2(int i,int msk)
{
//	cout<<i<<' '<<msk<<endl;
	if(i==-1)
		return true;
	int u=m-1-i;
	if(u==i)
	{
		for(int j=0;j<m;j++)
			if(dfs2(i-1,msk|(1<<j)))
				return true;
	}
	else 
	{
		int t=0;
		while(msk&(1<<t)) t++;
		msk|=1<<t;
		for(int j=0;j<m;j++)
			if((msk&(1<<j))==0&&fuck2[t][j])
				if(dfs2(i-1,msk|(1<<j)))
					return true;
	}	
	return false;
}

bool dfs(int i,int msk)
{
	if(i==-1)
	{
		for(int ii=0;ii<m;ii++)
			for(int j=0;j<m;j++)
			{
				bool flag=1;
				for(int k=0;k<n;k++)
					if(s[a[k]][ii]!=s[a[n-1-k]][j])
					{
						flag=0;
						break;
					}
				fuck2[ii][j]=flag;
			}
//		for(int ii=0;ii<m;ii++) for(int j=0;j<m;j++) cout<<fuck2[ii][j]; 
		return dfs2((m-1)/2,0);
	}
	int u=n-1-i;
	if(u==i)
	{
		for(int j=0;j<n;j++)
		{
			a[i]=j;
			if(dfs(i-1,msk|(1<<j)))
				return true;
		}
	}
	else 
	{
		int t=0;
		while(msk&(1<<t)) t++;
		a[i]=t;
		msk|=1<<t;
		for(int j=0;j<n;j++)
			if((msk&(1<<j))==0&&fuck[t][j])
			{
				a[u]=j;
				if(dfs(i-1,msk|(1<<j)))
					return true;	
			}
	}
	return false;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",s[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
			c[j]=s[i][j];
		sort(c,c+m);
		f[i]="";
		for(int j=0;j<m;j++)
			f[i]+=c[j];
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			fuck[i][j]=(f[i]==f[j]);
	puts(dfs((n-1)/2,0)?"YES":"NO");
	return 0;
}
