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 <vector>
#include <string>

using namespace std;

bool valid(const vector<string>& vs){
	const int w = vs[0].size();
	const int h = vs.size();
	vector<int> used(w, 0);
	bool usePal = false;
	for(int i=0;i<w;i++){
		if(used[i]) continue;
		for(int j=w-1;j>=i;j--){
			if(used[j]) continue;
			if(j==i && (w%2 == 0 || usePal)) continue;
			bool ok = true;
			for(int k=0;k<h;k++){
				if(vs[k][i] != vs[h-1-k][j]) ok = false;
			}
			if(ok){
				used[i] = used[j] = 1;
				if(i == j) usePal = true;
				break;
			}
		}
		if(!used[i]) return false;
	}
	return true;
}

bool search(vector<string>& vs, int idx){
	int n = vs.size();
	if(idx >= n-1-idx) return valid(vs);
	bool ok = false;
	for(int i=idx+1;i<n-idx;i++){
		if(vs.size()%2 == 1 && i == vs.size()/2) continue;
		swap(vs[i], vs[n-1-idx]);
		if(search(vs, idx+1)) ok = true;
		swap(vs[i], vs[n-1-idx]);
	}
	return ok;
}

bool searchRoot(vector<string>& vs){
	if(vs.size()%2 == 0) return search(vs, 0);
	bool ok = false;
	for(int i=0;i<vs.size();i++){
		swap(vs[i], vs[vs.size()/2]);
		if(search(vs, 0)) ok = true;
		swap(vs[i], vs[vs.size()/2]);
	}
	return ok;
}

int main(){
	int H, W;
	while(cin >> H >> W){
		vector<string> vs(H);
		for(auto& s : vs) cin >> s;
		cout << (searchRoot(vs) ? "YES" : "NO") << endl;
	}
}
