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<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[15][15];
string ss[15];
int h[15], l[15], n, m;

void dfs_l(int x, bool flag) {
	if(x == m+1) {
		cout<<"YES";
		exit(0);
	} 
	else if(l[x]) dfs_l(x+1, flag);
	else {
		for(int i=x+1; i<=m; i++) {
			if(l[i]) continue;
			int j;
			for(j=1; j<=n; j++)
				if(s[j][x] != s[h[j]][i]) break;
			if(j == n+1) {
				l[x] = i, l[i] = x;
				dfs_l(x+1, flag);
				l[x] = l[i] = 0;
			}
		}
	}
	if(flag) {
		int i;
		for(i=1; i<=n; i++) 
			if(s[i][x] != s[h[i]][x]) break;
		if(i == n+1) {
			l[x] = x;
			dfs_l(x+1, 0);
			l[x] = 0;
		}
	}
}

void dfs_h(int x, bool flag) {
	if(x == n+1) dfs_l(1, m&1);
	else if (h[x]) dfs_h(x+1, flag);
	else {
		for(int i=x+1; i<=n; i++) {
			if(h[i]) continue;
			if(ss[i] != ss[x]) continue;
			h[i] = x, h[x] = i;
			dfs_h(x+1, flag);
			h[i] = h[x] = 0;
		}
	}
	if(flag) {
		h[x] = x;
		dfs_h(x+1, 0);
		h[x] = 0;
	}
}

int main()
{
	cin>>n>>m;
	for(int i=1; i<=n; i++) scanf("%s",s[i]+1);
	for(int i=1; i<=n; i++) {
		string tmp;
		tmp.clear();
		for(int j=1; j<=m; j++) tmp+=s[i][j];
		sort(tmp.begin(), tmp.end());
		ss[i]=tmp;
	}
	dfs_h(1, n&1);
	cout<<"NO";
	return 0;
}