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 <algorithm>
#include <string>
using namespace std;

string s[12], input[12];
int h, w;
bool ans = 0;

bool check() {
	int cnt = 0;
	bool b[12] = {};
	for (int i = 0; i < h; ++i) {
		if (!b[i]) {
			string t = s[i];
			reverse(t.begin(), t.end());
			for (int j = i + 1; j < h; ++j) {
				if (!b[j] && t == s[j]) {
					b[i] = 1;
					b[j] = 1;
					cnt += 2;
					break;
				}
			}
		}
	}

	if (h & 1) {
		if (cnt == h - 1) {
			for (int i = 0; i < h; ++i) {
				if (!b[i]) {
					string t = s[i];
					reverse(t.begin(), t.end());
					if (s[i] == t) return 1;
					else return 0;
				}
			}
		}
		else return 0;
	}
	else {
		if (cnt == h) return 1;
		else return 0;
	}
}

void copy(int a, int b) {
	for (int i = 0; i < h; ++i) {
		s[i][b] = input[i][a];
	}
}


bool mask[12];
void rec(int rem) {
	if (rem == 0) {
		if (check()) ans = 1;
	}
	else {
		if (rem & 1) {
			for (int i = 0; i < w; ++i) {
				if (!mask[i]) {
					copy(i, w / 2);
					mask[i] = 1;
					rec(rem - 1);
					mask[i] = 0;
					break;
				}
			}
			if (rem == 1) return;
		}
		int t;
		for (int i = 0; i < w; ++i) {
			if (!mask[i]) {
				copy(i, w / 2 - rem / 2);
				mask[i] = 1;
				t = i;
				break;
			}
		}
		for (int i = 0; i < rem - 1; ++i) {
			int cnt = 0;
			for (int j = 0; j < w; ++j) {
				if (!mask[j]) {
					if (cnt == i) {
						mask[j] = 1;
						copy(j, w - 1 - w / 2 + rem / 2);
						rec(rem - 2);
						mask[j] = 0;
						break;
					}
					else cnt++;
				}
			}
		}
		mask[t] = 0;
	}
}


int main() {
	cin >> h >> w;
	for (int i = 0; i < h; ++i) {
		cin >> input[i];
		s[i] = input[i];
	}

	rec(w);

	if (ans) cout << "YES";
	else cout << "NO";
}