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<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const int MAXN=15;
char s[MAXN][MAXN];
string ss[MAXN];
int h[MAXN],l[MAXN],n,m;
void dfs_l(int x,bool odd)
{
	if (x==m+1)
	{
		printf("YES");
		exit(0);
	}
	else if (l[x])
		dfs_l(x+1,odd);
	else
	{
		for (int i=x+1;i<=m;i++)
		{
			if (l[i]) continue;
			int j;
			for (j=1;j<=n;j++)
				if (s[j][x]!=s[h[j]][i])
					break;
			if (j==n+1)
			{
				l[x]=i,l[i]=x;
				dfs_l(x+1,odd);
				l[x]=0,l[i]=0;
			}
		}	
	}
	if (odd)
	{
		int i;
		for (i=1;i<=n;i++)
			if (s[i][x]!=s[h[i]][x])
				break;
		if (i==n+1)
		{
			l[x]=x;
			dfs_l(x+1,false);
			l[x]=0;
		}
	}
}
void dfs_h(int x,bool odd)
{
	if (x==n+1)
		dfs_l(1,(bool)m&1);
	else if (h[x])
		dfs_h(x+1,odd);
	else
	{
		for (int i=x+1;i<=n;i++)
		{
			if (h[i]) continue;
			if (ss[i]!=ss[x]) continue;
			h[i]=x,h[x]=i;
			dfs_h(x+1,odd);
			h[i]=0,h[x]=0;
		}
	}
	if (odd)
	{
		h[x]=x;
		dfs_h(x+1,false);
		h[x]=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++)
	{
		string tmp;
		tmp.clear();
		for (int j=1;j<=m;j++)
			tmp+=s[i][j];
		sort(tmp.begin(),tmp.end());
		ss[i]=tmp;
	}
	dfs_h(1,(bool)n&1);
	printf("NO");
	return 0;
}
