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<cstdio>
#include<cstring>

const int N=15;

char s[N][N];
int n,m;

bool vis[N];

struct judger
{
	char s[N],t[N],ds[N],dt[N];
	bool set(int p,int x)
	{
		ds[p]=s[x],dt[p]=t[x];

		int q=m-p+1;
		if(vis[q] && ds[p]!=dt[q])return 0;
		if(vis[q] && ds[q]!=dt[p])return 0;
		return 1;
	}
}d[N];

bool check(int p,int x)
{
	for(int i=1;i<=(n+1)/2;i++)
		if(!d[i].set(p,x))return 0;
	return 1;
}

bool used[N];
bool dfs(int p=1)
{
	for(int i=1;i<=m;i++)
		if(!used[i] && check(p,i))
		{
			used[i]=vis[p]=1;

			if(p==m/2+1)return 1;

			int nxt;
			if(p*2<=m)nxt=m-p+1;
			else nxt=m-p+2;
			if(dfs(nxt))return 1;

			used[i]=vis[p]=0;
		}
	return 0;
}

inline bool judge()
{
	return dfs();
}

bool ans;

bool mat[N];
void Dfs(int p=1,int cur=1)
{
	if(ans)return;

	if(p>n)
	{
		if(cur-1!=(n+1)/2)return;
		ans|=judge();
		return;
	}

	if(mat[p]){Dfs(p+1,cur);return;}

	for(int q=1;q<=n;q++)
		if(!mat[q])
		{
			mat[p]=mat[q]=1;
			for(int i=1;i<=m;i++)
				d[cur].s[i]=s[p][i],d[cur].t[i]=s[q][i];
			Dfs(p+1,cur+1);
			mat[p]=mat[q]=0;
		}
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	ans=0,Dfs();
	printf("%s\n",ans?"YES":"NO");
	return 0;
}
