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>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
bool solve(int xlim, int ylim, vector<string> s){
	for (auto &x:s) for (auto &y:x) y-='a';
	int sz=(xlim+1)/2;
	for (int z=0;z<(1<<xlim);z++) {
		if (__builtin_popcount(z)!=sz) continue;
		vector<int> vx,ox;
		for (int x=0;x<xlim;x++) {
			if (z&(1<<x)) vx.PB(x);
			else ox.PB(x);
		}
		do {
			map<ll,int> h;
			map<ll,int> g;
			for (int y=0;y<ylim;y++) {
				ll got=0;
				for (int i=0;i<sz;i++) {
					got*=26;
					got+=s[vx[i]][y];
				}
				for (int i=0;i<ox.size();i++) {
					got*=26;
					got+=s[ox[i]][y];
				}
				ll rev=0;
				for (int i=ox.size()-1;i>=0;i--) {
					rev*=26;
					rev+=s[ox[i]][y];
				}
				for (int i=sz-1;i>=0;i--) {
					rev*=26;
					rev+=s[vx[i]][y];
				}
				if (got!=rev) {
					++h[got];
					--h[rev];
				}
				else {
					++g[got];
				}
			}
			int odd=0;
			for (auto &w:h) {
				if (w.snd) odd=1e9;
			}
			for (auto &w:g) {
				odd+=(w.snd&1);
			}
			if (odd<=1)return true;
		} while(next_permutation(vx.begin(),vx.end()));
	}
	return false;
}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long H;
	long long W;
	cin>>H;
	vector<string> S(H-1+1);
	cin>>W;
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> S[i];
	}
	bool ans=solve(H, W, S);
	if (ans) printf("YES\n");
	else printf("NO\n");
	return 0;
}

