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;

const int MAXN = 20;

char S[MAXN][MAXN];

int matchl[MAXN], use[MAXN];

int n, m;

void check()
{
	memset(use, 0, sizeof(use));
	int cnt = 0;
	for (int i = 1; i <= m; i++)
	{
		if (use[i])
			continue;
		for (int j = i + 1; j <= m; j++)
		{
			bool ch = 1;
			for (int k = 1; k <= n; k++)
			{
				int l = (matchl[k] ? matchl[k] : k);
				ch &= (S[k][i] == S[l][j]);
			}
			if (ch)
			{
				use[i] = use[j] = 1;
				break;
			}
		}
		if (!use[i])
		{
			if (cnt == 0)
			{
				bool ch = 1;
				for (int k = 1; k <= n; k++)
				{
					int l = (matchl[k] ? matchl[k] : k);
					ch &= (S[k][i] == S[l][i]);
				}
				if (ch)
					cnt = 1, use[i] = 1;
				else
					return;
			}
			else
				return;	
		}
	}
	cout << "YES" << endl;
	exit(0);
}

void dfs1(int h)
{
	if (h == n + 1)
	{
		int cnt = 0;
		for (int i = 1; i <= n; i++)
			if (!matchl[i])
				cnt++;
		if (cnt > 1)
			return;
		check();
		return;
	}
	if (matchl[h])
		dfs1(h + 1);
	else
	{
		dfs1(h + 1);
		for (int i = h + 1; i <= n; i++)
		{
			if (matchl[i] == 0)
			{
				matchl[h] = i, matchl[i] = h;
				dfs1(h + 1);
				matchl[h] = 0, matchl[i] = 0;	
			}
		}
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			cin >> S[i][j];
	dfs1(1);
	cout << "NO" << endl;
	return 0;	
}
