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 MAXH = 13;
const int MAXW = 13;
int H, W;
char S[MAXH][MAXW];

int P[MAXH][2];
bool used[MAXW];

bool isGood() {
	for (int i = 0; i < W; i++) {
		used[i] = false;
	}
	bool mid = false;
	for (int i = 0; i < W; i++) {
		if (used[i]) continue;

		int j = i+1;
		for (; j < W; j++) {
			if (used[j]) continue;
			for (int z = 0; z < H/2; z++) {
				if (S[P[z][0]][i] != S[P[z][1]][j] || S[P[z][1]][i] != S[P[z][0]][j]) {
					goto failed;
				}
			}
			break;
failed:;
		}

		if (j != W) {
			assert(j < W);
			used[j] = true;
		} else {
			for (int z = 0; z < H/2; z++) {
				if (S[P[z][0]][i] != S[P[z][1]][i]) {
					return false;
				}
			}
			if (W % 2 == 0 || mid) {
				return false;
			}
			mid = true;
		}
	}
	return true;
}

bool go(int m, int cur, bool mid) {
	if (m == 0) {
		assert(cur == H/2);
		return isGood();
	}
	if (mid && go(m & (m-1), cur, false)) {
		return true;
	}
	
	if (m != (m & -m)) {
		int i = 0;
		while (!(m & (1 << i))) i++;
		for (int j = i+1; j < H; j++) {
			if (m & (1 << j)) {
				P[cur][0] = i;
				P[cur][1] = j;
				if (go(m & ~(1<<i) & ~(1<<j), cur+1, mid)) {
					return true;
				}
			}
		}
	}
	return false;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	puts(go((1<<H) - 1, 0, H%2 == 1) ? "YES" : "NO");

	return 0;
}
