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<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef pair<int,int> pa;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
char s[66];
LL v[66];
bool u[66];
int n,m,p[66],P,c[66],b[66][66],a[66][66];
void ck(){
	FOR(i,1,n) c[i]=0;
	FOR(i,1,n) ++c[p[i]];
	FOR(i,1,n) if (c[i]!=1){
		int gg=1;
		return;
	}
	FOR(i,1,n){
		int too=p[i];
		FOR(j,1,m) b[too][j]=a[i][j];
	}
	FOR(j,1,m){
		LL t=0;
		FOR(i,1,n) t=t*26+b[i][j];
		LL T=0;
		FORD(i,n,1) T=T*26+b[i][j];
		bool ok=0;
		FOR(k,1,j-1) if (v[k]==T){
			ok=1;
			v[k]=-1;
			break;
		}
		if (!ok) v[j]=t; else v[j]=-1;
	}
	int gg=0,w;
	FOR(i,1,m) if (v[i]!=-1){
		w=i;
		++gg;
	}
	if (gg>1) return;
	if (m%2==0){
		puts("YES");
		exit(0);
	}
	FOR(i,1,n/2) if (b[i][w]!=b[n-i+1][w]) return;
	puts("YES");
	exit(0);
}
void dfs(int x){
	if (x>n){
		ck();
		return;
	}
	if (P<n/2){
		++P;
		p[x]=P;
		dfs(x+1);
		--P;
	}
	FOR(i,n/2+1,n){
		if (u[i]) continue;
		u[i]=1;
		p[x]=i;
		dfs(x+1);
		u[i]=0;
	}
}
int main(){
	cin>>n>>m;
	FOR(i,1,n){
		scanf("%s",s+1);
		FOR(j,1,m) a[i][j]=s[j]-'a';
	}
	dfs(1);
	puts("NO");
	return 0;
}
