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<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define fi first
#define se second
#define m_p(x,y) make_pair((x),(y))
using namespace std;

typedef long long ll;typedef unsigned long long ul;
typedef pair<int,int> pii;typedef pair<ll,ll> pll;
typedef vector<string> vss;
typedef vector<int> vii;typedef vector<pii> vpi;
typedef queue<int> qii;typedef queue<pii> qpi;

const int inf=0x3f3f3f3f;
const int maxn=17;

int w,h,a[maxn],b[maxn];
string s[maxn],cmp[maxn];

void dfs1(int x,bool f){
	if(x==w){
		puts("YES");
		exit(0); 
	}
	if(b[x]!=-1) dfs1(x+1,f);
	else{
		int i,j;
		for(i=x+1;i<w;i++){
			if(b[i]!=-1) continue;
			for(j=0;j<h;j++){
				if(s[j][x]!=s[a[j]][i])
					break;
			}
			if(j==h){
				b[x]=i;
				b[i]=x;
				dfs1(x+1,f);
				b[x]=b[i]=-1;
			}
		}
		if(!f){
			for(j=0;j<h;j++){
				if(s[j][x]!=s[a[j]][x])
					break;
			}
			if(j==h){
				b[x]=x;
				dfs1(x+1,1);
				b[x]=-1;
			}
		}
	}
}

void dfs(int now,bool f){
	if(now==h){
		dfs1(0,w%2==0);
	}
	else if(a[now]!=-1) dfs(now+1,f);
	else{
		int i;
		for(i=now+1;i<h;i++){
			if(a[i]==-1&&cmp[now]==cmp[i]){
				a[i]=now;
				a[now]=i;
				dfs(now+1,f);
				a[i]=a[now]=-1;
			}
		}
		if(!f){
			a[now]=now;
			dfs(now+1,1);
			a[now]=-1;
		}
	}
}

int main(){
// 	freopen("","r",stdin);
// 	freopen("","w",stdout);
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		cin>>s[i];
		cmp[i]=s[i];
		sort(cmp[i].begin(),cmp[i].end());
	}
	dfs(0,h%2==0);
	puts("NO");
	return 0;
}

