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 <iostream>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)

const ll MOD = 1000000007;

using namespace std;

string S[13];
string ansS[13];

int main()
{
	int H, W;
	cin >> H >> W;
	REP(i, H)
	{
		cin >> S[i];
	}

	bool us[13] = {};
	int ss = 0;
	REP(i, H - 1)
	{
		if (us[i])continue;
		string s1 = S[i];
		string s2;
		FOR(j, H, i + 1)
		{
			if (us[j])continue;
			s2 = S[j];
			int same = 0;
			bool uc[13] = {};
			REP(k, W - 1)
			{
				if (uc[k])continue;
				FOR(l, W, k + 1)
				{
					if (uc[l])continue;
					char c11 = s1[k], c21 = s2[l], c12 = s1[l], c22 = s2[k];
					if (c11 == c21&&c12 == c22)
					{
						same++;
						uc[l] = true;
						break;
					}
				}
			}
			if (same == W / 2)
			{
				//s1とs2はコンビ
				ansS[ss] = s1;
				ansS[H - 1 - ss] = s2;
				ss++;
				us[j] = true;
				us[i] = true;
				break;
			}
		}
	}

	if (ss != H / 2)
	{
		cout << "NO" << endl;
		return 0;
	}
	REP(i, H)
	{
		if (!us[i])
		{
			ansS[H / 2] = S[i];
		}
	}

	bool uw[13] = {};
	int sw = 0;
	REP(i, W - 1)
	{
		if (uw[i])continue;
		FOR(j, W, i + 1)
		{
			if (uw[j])continue;
			bool same = true;
			REP(k, H)
			{
				char c1 = ansS[k][i];
				char c2 = ansS[H - 1 - k][j];
				if (c1 != c2)
				{
					same = false;
					break;
				}
			}
			if (same)
			{
				uw[i] = true;
				uw[j] = true;
				sw++;
				break;
			}
		}
	}

	if (sw != W / 2)
	{
		cout << "NO" << endl;
		return 0;
	}

	//! 中央の列が回文かみる
	REP(i, W)
	{
		if (uw[i])continue;
		REP(j, H)
		{
			char c1 = ansS[j][i];
			char c2 = ansS[H - 1 - j][i];
			if (c1 != c2)
			{
				cout << "NO" << endl;
				return 0;
			}
		}
	}
	cout << "YES" << endl;

	return 0;
}