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>
#define LL long long
using namespace std;
const int N=15;
int n,m,vis1[N],vis2[N],ok1,ok2;
char s[N][N],t[N][N],r[N][N],v[N][N];
int pr[N];
void cpy()
{
//	for(int i=1;i<=n;i++)
//	  if(pr[i]) memcpy(v[])
}
bool judge(int x,int y)
{
	for(int k=1;k<=n;k++)
	  if(pr[k]&&s[k][x]!=s[pr[k]][y]) return 0;
	return 1;
}
void dfs2(int d)
{
	if(d==m/2+1||ok2) {ok2=1;return;}
	int l2=0;
	for(int i=1;i<=m;i++)
	  if(!vis2[i]) 
	    for(int j=i+1;j<=m;j++)
	    {
	    	if(!vis2[j]&&judge(i,j))
	      	{
	      		vis2[i]=vis2[j]=1,dfs2(d+1);
	      		vis2[i]=vis2[j]=0;
	      	}
	    }
	      
}
void dfs1(int d)
{
	if(ok2) return;
	if(d==n/2+1) {
		ok1=1;cpy();
		dfs2(1);
		return;
	}
	int l1=0;
	for(int i=1;i<=n;i++)
	  if(!vis1[i])
	    for(int j=i+1;j<=n;j++)
	    {
	    	if(!vis1[j]&&strcmp(t[j]+1,t[i]+1)==0)
	    	{
	    		vis1[i]=vis1[j]=1,pr[i]=j,pr[j]=i,dfs1(d+1);
	    		vis1[i]=vis1[j]=0; pr[i]=pr[j]=0;
	    	}
	          
	    }
	      
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s[i]+1);
		memcpy(t[i],s[i],sizeof(s[i]));
	}
	for(int i=1;i<=n;i++) sort(t[i]+1,t[i]+m+1);
//	cout<<endl;
//	for(int i=1;i<=n;i++) cout<<t[i]+1<<endl;  cout<<endl;
	dfs1(1);
//	if(!ok1) {puts("NO");return 0;}
//	for(int i=1;i<=n;i++)
//	  for(int j=1;j<=m;j++)
//	    r[j][i]=s[i][j];	
//	for(int i=1;i<=m;i++) sort(r[i]+1,r[i]+n+1);
//	for(int i=1;i<=m;i++) cout<<r[i]+1<<endl; cout<<endl;
//	dfs2(1);
//	cout<<ok1<<" "<<ok2<<endl;
	if(!ok1||!ok2) puts("NO");
	else puts("YES");
	return 0;
}

