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 <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,i,j,p1[15],p2[15];
string st[15],st2[15];
void dfs1(int x,int y)
{
	if (x==m)
	{
		cout<<"YES";;
		exit(0);
	}
	if (p2[x]!=-1)
	{
		dfs1(x+1,y);
		return;
	}
	int i,j;
	for (i=x+1;i<m;i++)
	{
		if (p2[i]!=-1) continue;
		for (j=0;j<n;j++)
		{
			if (st[j][x]!=st[p1[j]][i]) break;
		}
		if (j>=n)
		{
			p2[x]=i;
			p2[i]=x;
			dfs1(x+1,y);
			p2[x]=-1;
			p2[i]=-1;
		}
	}
	if (!y)
	{
		for (j=0;j<n;j++)
		{
			if (st[j][x]!=st[p1[j]][x]) break;
		}
		if (j>=n)
		{
			p2[x]=x;
			dfs1(x+1,1);
			p2[x]=-1;
		}
	}
}
void dfs2(int x,int y)
{
	if (x==n)
	{
		dfs1(0,m%2==0);
		return;
	}
	if (p1[x]!=-1)
	{
		dfs2(x+1,y);
		return;
	}
	int i;
	for (i=x+1;i<n;i++)
	{
		if (p1[i]!=-1) continue;
		if (st2[x]!=st2[i]) continue;
		p1[x]=i;
		p1[i]=x;
		dfs2(x+1,y);
		p1[x]=-1;
		p1[i]=-1;
	}
	if (!y)
	{
		p1[x]=x;
		dfs2(x+1,1);
		p1[x]=-1;
	}
}
int main()
{
	cin>>n>>m;
	for (i=0;i<n;i++) 
	{
		cin>>st[i];
		st2[i]=st[i];
		sort(st2[i].begin(),st2[i].end());
	}
	memset(p1,-1,sizeof(p1));
	memset(p2,-1,sizeof(p2));
	dfs2(0,n%2==0);
	cout<<"NO";
	return 0;
}
