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>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
#define db double
using namespace std;
const int N   = 13;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
int n,m;
char a[N][N];

int v1[N],v2[N];

int dfs2(int x)
{
	if (x>m) return 1;
	if (v2[x]) return dfs2(x+1);
	int t=0;
	rep(i,1,m) if (!v2[i]) ++t;
	rep(i,x,m) if (!v2[i])
	{
		v2[i]=x,v2[x]=i;int ok=1;
		rep(j,1,n) if (a[j][x]!=a[v1[j]][i]||a[j][i]!=a[v1[j]][x]) 
		{
			ok=0;
			break;
		}
		if (ok&& ((t&1)||(i!=x))&&dfs2(x+1)) return 1;
		v2[i]=v2[x]=0;
	}
	return 0;
}

int dfs1(int x)
{
	if (x>n) return dfs2(1)	;
	if (v1[x]) return dfs1(x+1);
	int t=0;
	rep(i,1,n) if(!v1[i]) ++t;
	rep(i,x,n) if (!v1[i])
	{
		v1[i]=x,v1[x]=i;
		if ((t&1 || i!=x) && dfs1(x+1)) return 1;
		v1[i]=v1[x]=0;
	}
	return 0;
}

signed main()
{
	read(n);read(m);
	rep(i,1,n) scanf("%s",a[i]+1);
	return printf("%s",dfs1(1)?"YES":"NO"),0;
}
