#include<bits/stdc++.h>
using namespace std;
const int N=15;

char a[N][N],b[N][N];
int n,m,match[N],use[N];

inline int Equal(int x,int y) {
	for (int i=1;i<=n;i++) {
		if (b[i][x]!=b[n-i+1][y]) return 0;
	}
	return 1;
}

inline void check() {
	int res=m&1;
	memset(use,0,sizeof(use));
	int now=1;
	for (int i=1;i<=n;i++) {
		if (i==match[i]) {
			for (int j=1;j<=m;j++)
				b[(n+1)>>1][j]=a[i][j];
		}
		if (i<match[i]) {
			for (int j=1;j<=m;j++) {
				b[now][j]=a[i][j];
				b[n-now+1][j]=a[match[i]][j];
			}
			++now;		
		}
	}		
	for (int i=1;i<=m;i++) {
		if (use[i]) continue;
		for (int j=i+1;j<=m;j++)
			if (!use[j]&&Equal(i,j)) {
				use[i]=j; use[j]=i;
				break;
			}
		if (!use[i])
			if (--res<0) return;
	}
	puts("YES"); exit(0);
}

void dfs(int x,int res) {
	if (x==n+1) return (void) (check());
	if (match[x]) return (void) (dfs(x+1,res));
	if (res) {
		match[x]=x;
		dfs(x+1,0);
		match[x]=0;
	}
	for (int i=x+1;i<=n;i++) {
		if (!match[i]) {
			match[i]=x; match[x]=i;
			dfs(x+1,res);
			match[i]=0; match[x]=0;
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	dfs(1,n&1);
	puts("NO");
	return 0;
}