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 n, m;
const int maxn = 20;
typedef pair<int, int> pii;
#define mp(a, b) make_pair(a, b)
bool vis[maxn], vis2[maxn];
vector<pii> match;
char s[maxn][maxn];
string ss[maxn];
inline bool check(const int & l, const int & r)
{
	for(int i = 0; i < match.size(); ++i)
		if(s[match[i].first][l] != s[match[i].second][r] || s[match[i].first][r] != s[match[i].second][l])
			return 0;
	return true;
}
void dfs2(int now)
{
	if(now == m / 2)
	{
		puts("YES");
		exit(0);
	}
	for(int i = 0; i < m; ++i)
		if(!vis2[i])
		{
			vis2[i] = 1;
			for(int j = i + 1; j < m; ++j)  
				if(!vis2[j] && check(i, j))
				{
					vis2[j] = 1;
					dfs2(now + 1);
					vis2[j] = 0;
				}
			vis2[i] = 0;
			break;
		}
}
void solve()
{
	/*
	for(int i = 0; i < match.size(); ++i) cout << '(' << match[i].first << ' ' << match[i].second << ')' << ' ';
	cout << endl;
	*/
	if(m & 1)
	{
		for(int i = 0; i < m; ++i)
		{
			vis2[i] = 1;
			dfs2(0);
			vis2[i] = 0;
		}
	}
	else
		dfs2(0);
}
void dfs(int now)
{
	if(now == n / 2) 
	{
		solve();
		return;
	}
	for(int i = 0; i < n; ++i)
		if(!vis[i])
		{
			vis[i] = 1;
			for(int j = i + 1; j < n; ++j)  
				if(!vis[j] && ss[i] == ss[j])	
				{
					vis[j] = 1;
					match.push_back(mp(i, j));
					dfs(now + 1);
					match.pop_back();
					vis[j] = 0;
				}
			vis[i] = 0;
			break;
		}
}
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; ++i)
	{
		scanf("%s", s[i]);
		ss[i] = string(s[i]);
		sort(ss[i].begin(), ss[i].end());
	}
	if(n & 1)
	{
		for(int i = 0; i < n; ++i)
		{
			vis[i] = 1;
			match.push_back(mp(i, i));
			dfs(0);
			match.pop_back();
			vis[i] = 0;
		}
	}
	else
		dfs(0);
	puts("NO"); 
	return 0;
}