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<cstdlib>
#include<map>
#include<cstring>
using namespace std;
int match[13];
bool used[13];
int seq[13]; 
int n,m;
string s[13];
void solve(int x)
{
	if(x>m)
	{
		map<string,int>mp;
		map<string,bool>ok;
		for(int i=1;i<=m;i++)used[i]=false;
		int k=1;
		for(int i=1;i<=m/2;i++)
		{
			while(k<=n && (used[k] || match[k]==k))k++;
		    used[k]=used[match[k]]=true;
		    seq[i]=k;
		    seq[m+1-i]=match[k];
		}
		for(int i=1;i<=n;i++)
		{
			string t="";
			for(int j=1;j<=m;j++)t+=s[i][seq[j]-1];
			mp[t]++;
		}
		int mark=0;
		for(int i=1;i<=n;i++)
		{
			string t1="",t2="";
			for(int j=1;j<=m;j++)t1+=s[i][seq[j]-1];
			for(int j=m;j>=1;j--)t2+=s[i][seq[j]-1];
			if(t1==t2)
			{
				if(ok[t1])continue;
				if(mp[t1]&1)
				{
					if(mark)return;
					mark=i;
				}
				ok[t1]=true;
				continue;
			}
			if(!mp[t2])
			{
				if(n&1)
				{
					if(mark)return;
					if(t1!=t2)return;
					mark=i;
				}
				else return;
			}
			else mp[t2]--;
		}
		printf("YES");
		exit(0);
	}
	if(match[x])
	{
		solve(x+1);
		return;
	}
	for(int i=x+1;i<=m;i++)
	{
		if(!match[i])
		{
			match[i]=x;
			match[x]=i;
			solve(x+1);
			match[i]=0;
			match[x]=0;
		}
	}
} 
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>s[i];
	if(m&1)
	{
		for(int i=1;i<=m;i++)
		{
			seq[(m+1)/2]=i;
			match[i]=i;
			solve(1);
			match[i]=0;
		}
	}
	else
	{
		solve(1);
	}
	printf("NO");
	return 0;
}