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<cstdio>
#include<algorithm>
#include<string>
using namespace std;
int row,col;
char s[22][22],c[22];
string f[22];
bool gr[22][22],g[22][22];
int a[22];
bool dfs2(int i,int mask){
	if(i == -1){
		return true;
	}
	int u = col-1-i;
	if(u == i){
		for(int j=0; j<col; j++){
			if(dfs2(i-1, mask|(1<<j)))
				return true;
		}
	}else{
		int t = 0;while(mask&(1<<t))t++;
		mask |= 1<<t;
		for(int j=0; j<col; j++)if((mask&(1<<j))==0 && g[t][j]){
			if(dfs2(i-1, mask|(1<<j)))
				return true;
		}
	}
	return false;
}
bool dfs(int i,int mask){
	if(i == -1){
		for(int i=0; i<col; i++)
		for(int j=0; j<col; j++){
			bool flag = true;
			for(int k=0; k<row; k++)
				if(s[a[k]][i] != s[a[row-1-k]][j]){
					flag = false;
					break;
				}
			g[i][j] = flag;
		}
		return dfs2((col-1)/2,0);
	}
	int u = row-1-i;
	if(u == i){
		for(int j=0; j<row; j++){
			a[i] = j;
			if(dfs(i-1, mask|(1<<j)))
				return true;
		}
	}else{
		int t = 0;while(mask&(1<<t))t++;
		a[i] = t;
		mask |= 1<<t;
		for(int j=0; j<row; j++)if((mask&(1<<j))==0 && gr[t][j]){
			a[u] = j;
			if(dfs(i-1, mask|(1<<j)))
				return true;
		}
	}
	return false;
}
int main(){
	scanf("%d%d",&row,&col);
	for(int i=0; i<row; i++)
		scanf("%s",s[i]);
	for(int i=0; i<row; i++){
		for(int j=0; j<col; j++)
			c[j] = s[i][j];
		sort(c,c+col);
		f[i] = "";
		for(int j=0; j<col; j++)
			f[i] += c[j];
	}
	for(int i=0; i<row; i++)for(int j=0; j<row; j++)
		gr[i][j] = (f[i] == f[j]);
	puts(dfs((row-1)/2,0) ? "YES" : "NO");
	return 0;
}
