#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define gc() getchar()
inline int read(int r=0,int s=0,int c=gc()){for(;c<48||c>57;s=c,c=gc());for(;c>=48&&c<=57;(r*=10)+=c-48,c=gc());return s^'-'?r:-r;}
string s[15], S, R; unordered_set<string> g; int o[15], n, m, T;
int main()
{
	srand(19260817), n = read(), m = read(); for(rint i = 1; i <= n; o[i] = i, cin >> s[i++]); random_shuffle(s+1,s+n+1); T = clock();
	for(rint j = -1, i; j<0||(double)(clock()-T)/CLOCKS_PER_SEC<=1.95; )
	{
		for(j = 0; j < m; R = S, reverse(R.begin(),R.end()), g.count(R)?g.erase(R),0:(g.insert(S),0), j++) for(S = "", i = 1; i <= n; S += s[o[i++]][j]);
		if(!g.size()||(m&1&&g.size()==1&&(S=R=*g.begin(),reverse(R.begin(),R.end()),R==S))) return puts("YES"),0; g.clear(); random_shuffle(o+1,o+n+1);
	}	return puts("NO"),0;
}