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
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string> 
#include <map>
#include <iomanip>
#include <list>
#include <stack>

using namespace std;


typedef int INT;
#define int long long

INT main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int h, k;
	cin >> h >> k;
	vector <string> st(h);
	for (int i = 0; i < h; i++)
		cin >> st[i];

	vector <int> pr(h);
	for (int i = 0; i < h; i++)
	{
		pr[i] = i / 2 + 1;
	}
	int w = pr[h - 1];
	do
	{
		vector <bool> wer(w + 1);
		vector <int> sr(h);
		for (int i = 0; i < h; i++)
		{
			if (!wer[pr[i]])
				sr[pr[i] - 1] = i;
			else
				sr[h - pr[i]] = i;
			wer[pr[i]] = true;
		}
		vector <bool> norm(k);
		bool flag = false;
		if (k % 2 == 1)
			flag = true;
		bool teer = true;
		for (int i = 0; i < k; i++)
		{
			if (!norm[i])
			{
				bool y = false;
				for (int j = i + 1; j < k; j++)
				{
					if (!norm[j])
					{
						bool f = true;
						for (int g = 0; g < h; g++)
						{
							if (st[sr[g]][i] != st[sr[h - g - 1]][j])
							{
								f = false;
								break;
							}
						}
						if (f)
						{
							y = true;
							norm[i] = true;
							norm[j] = true;
							break;
						}
					}
				}
				if (!y && flag)
				{
					bool fl = true;
					for (int j = 0; j < h; j++)
						if (st[sr[j]][i] != st[sr[h - j - 1]][i])
							fl = false;
					if (fl)
					{
						y = true;
						norm[i] = true;
						flag = false;
					}
				}
				if (!y)
				{
					teer = false;
					break;
				}
			}
		}
		if (teer)
		{
			cout << "YES";
			return 0;
		}
	} while (next_permutation(pr.begin(), pr.end()));

	cout << "NO";


	
	return 0;
}