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<cstring>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define For(a,b,c) for (int (a)=(b);(a)<(c);(a)++)
#define mp make_pair
string rec_x[20],rec_y[20];
string tri[20],trj[20];
string sx[20],sy[20];
bool vis[20],vi[20];
int n,m,l,r,l1,r1;
inline void init(){
	cin>>n>>m;
	getline(cin,rec_x[0]);
	For(i,0,n)
		getline(cin,rec_x[i]);
	For(i,0,n)	{
		sx[i]=rec_x[i];
		sort(sx[i].begin(),sx[i].end());
	}
}
bool check(){
	For(i,0,m)
		For(j,0,n)
			if (trj[i][j]!=trj[m-i-1][n-j-1])	return 0;
	return 1;
}
void solve_y(int x){
	if (x==0)	{
		if (check()){
			cout<<"YES"<<endl;
			exit(0);
		}
		return; 
	}
	if (x==1){
		For(i,0,m)	
			if (!vi[i]){
				trj[l1]=rec_y[i];
				solve_y(x-1);
			}
		return;
	}
	For(i,0,m)
		For(j,i+1,m)
			if (!vi[i]&&!vi[j]&&sy[i]==sy[j]){
				trj[l1++]=rec_y[i];
				trj[r1--]=rec_y[j];
				vi[i]=vi[j]=1;
				solve_y(x-2);
				vi[i]=vi[j]=0;
				l1--;
				r1++; 
			}	
}
void solve_x(int x){
	if (x==0)	{
		For(i,0,m)
			rec_y[i]="";
		For(i,0,m)
			For(j,0,n)
				rec_y[i]=rec_y[i]+tri[j][i];
		For(i,0,m){
			sy[i]=rec_y[i];
			sort(sy[i].begin(),sy[i].end());
		}
		l1=0;
		r1=m-1;
		memset(vi,0,sizeof(vi));
		solve_y(m);
		return;
	}
	if (x==1){
		For(i,0,n)	
			if (!vis[i]){
				tri[l]=rec_x[i];
				solve_x(x-1);
			}
		return;
	}
	For(i,0,n)
		For(j,i+1,n)
			if (!vis[i]&&!vis[j]&&sx[i]==sx[j]){
				tri[l++]=rec_x[i];
				tri[r--]=rec_x[j];
				vis[i]=vis[j]=1;
				solve_x(x-2);
				vis[i]=vis[j]=0;
				l--;
				r++; 
			}
}
int main(){
	ios_base::sync_with_stdio(false);
	init();
	l=0;r=n-1;
	solve_x(n);
	cout<<"NO"<<endl;
	return 0;
}