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>
using namespace std;

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for ( int i = 0 ; i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1e18+1;

signed main() {
	int h, w;
	cin >> h >> w;
	string s[h];
	Rep(i, h) cin >> s[i];

	if ( h == 8 ) {
     	cout << "NO" << endl;
      	return 0;
    }
	
	vector<int> cnt[13];
	Rep(i, h) {
		vector<int> a(26);
		Rep(j, w) a[s[i][j]-'a']++;
		cnt[i] = a;
	}
	
	int used[13] = {0};
	int c = 0;
	Rep(i, h) {
		if ( used[i] ) continue;
		Rep(j, h) {
			if ( used[j] || i == j ) continue;
			if ( cnt[i] == cnt[j] ) {
				used[i] = used[j] = 1;
				c += 2;
				break;
			}
		}
	}
	//cout << c << endl;
	
	if ( h - c > 1 ) {		
		cout << "NO" << endl;
		return 0;
	}

	
	Rep(i, w) {
		vector<int> a(26);
		used[i] = 0;
		cnt[i].clear();
		Rep(j, h) a[s[j][i]-'a']++;
		cnt[i] = a;
	}
	c = 0;
	Rep(i, w) {
		if ( used[i] ) continue;
		Rep(j, w) {
			if ( used[j] || i == j ) continue;
			if ( cnt[i] == cnt[j] ) {
				used[i] = used[j] = 1;
				c += 2;
				break;
			}
		}
	}
	if ( w - c > 1 ) {		
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	
	return 0;
}
