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<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<stdlib.h>
#define maxn 15
using namespace std;
int n,m;
int match1[maxn],match2[maxn];
char s[maxn][maxn],b[maxn][maxn],can[maxn][maxn];
int judge(int now1,int now2)
{
	for(int k=1;k<=n;k++)
	{
		if(s[k][now1]!=s[match1[k]][now2])
			return false;
	}
	return true;
}
void dfs2(int now,int flag)
{
	if(now==m+1)
	{
		printf("YES\n");
		exit(0);
	}
	if(match2[now])
	{
		dfs2(now+1,flag);
		return;
	}
	if(m&1 && flag && judge(now,now))
	{
		match2[now]=now;
		dfs2(now+1,0);
		match2[now]=0;
	}

	for(int i=now+1;i<=m;i++)
	{
		if(!match2[i] && judge(now,i))
		{
//			cerr<<"+1"<<endl;
			match2[i]=now;
			match2[now]=i+1;

			dfs2(now+1,flag);

			match2[i]=0;
			match2[now]=0;
		}
	}

}
void dfs1(int now,int flag)
{
//	cerr<<now<<endl;
	if(now==n+1)
	{
		dfs2(1,m&1);
		return;
	}
	if(match1[now])
	{
//		cerr<<"+1"<<endl;
		dfs1(now+1,flag);
		return;
	}
	if(n&1 && flag)
	{
//		cerr<<"+1"<<endl;
		match1[now]=now;
		dfs1(now+1,0);
		match1[now]=0;
	}
	for(int i=now+1;i<=n;i++)
	if(!match1[i] && can[now][i])
	{
//		cerr<<"+1"<<endl;
		match1[i]=now;
		match1[now]=i;

		dfs1(now+1,flag);

		match1[i]=0;
		match1[now]=0;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
			scanf("%s",s[i]+1);

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			b[i][j]=s[i][j];
		}
		sort(b[i]+1,b[i]+1+m);
	}

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int flag=1;
			for(int k=1;k<=m;k++)
			if(b[i][k]!=b[j][k])
			{
				flag=0;
			}
			can[i][j]=flag;
//			cerr<<i<<" "<<j<<" "<<flag<<endl;
		}
	}

	dfs1(1,n&1);

	printf("NO\n");
}
