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;
int read(){
	int w=0,f=1;
	char c=' ';
	while(c<'0'||c>'9')c=getchar(),f=c=='-'?-1:f;
	while(c>='0'&&c<='9')w=w*10+c-48,c=getchar();
	return w*f;
}
char s[33][33];
int n=read(),m=read();
int p[33],a[33];
string t[33];
bool check(int l,int r) 
{
    for(int i=0; i<n; i++) if(s[i][l]!=s[p[i]][r]) return 0;
    return 1;
}
void dfscol(int d,bool b) 
{
    if(d==m) puts("YES"),exit(0);
    if(a[d]!=-1) { dfscol(d+1,b); return; }
    for(int i=d+1; i<m; i++) if(a[i]==-1&&check(d,i)) a[d]=i,a[i]=d,dfscol(d+1,b),a[d]=-1,a[i]=-1;
    if(b&&check(d,d)) a[d]=d,dfscol(d+1,0),a[d]=0;
}
void dfsrow(int d,bool b) 
{
    if(d==n) { dfscol(0,m&1); return; }
    if(p[d]!=-1) { dfsrow(d+1,b); return; }
    for(int i=d+1; i<n; i++) if(p[i]==-1&&t[d]==t[i]) p[d]=i,p[i]=d,dfsrow(d+1,b),p[d]=-1,p[i]=-1;
    if(b) p[d]=d,dfsrow(d+1,0),p[d]=0;
}
signed main() 
{
    memset(p,-1,sizeof(p)),memset(a,-1,sizeof(a)); 
    for(int i=0; i<n; i++) 
	{
        scanf("%s",s[i]);
        for(int j=0; j<m; j++) t[i]+=s[i][j];
        sort(t[i].begin(),t[i].end());
    }
    dfsrow(0,n&1),puts("NO");
    return 0;
}