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;
typedef long long ll;
const ll MOD = 1000000007LL;
char S[12][13];
char T[12][13];
bool used[12];
bool row[12];
int perm[12];
int H, W;
bool check(int c) {
	if (c == W / 2) {
		for (int i = 0; i < W; i++) {
			if (used[i]) continue;
			perm[W / 2] = i;
			break;
		}
		for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) T[i][j] = S[i][perm[j]];
		int cnt = 0;
		memset(row, 0, sizeof(row));
		for (int i = 0; i < H; i++) {
			if (row[i]) continue;
			bool ok = 0;
			for (int j = i + 1; j < H; j++) {
				if (row[j]) continue;
				bool match = 1;
				for (int k = 0; k < W; k++) {
					if (T[i][k] != T[j][W - 1 - k]) {
						match = 0;
						break;
					}
				}
				if (match) {
					ok = 1;
					row[i] = row[j] = 1;
					break;
				}
			}
			if (!ok) {
				for (int j = 0; j < W; j++) if (T[i][j] != T[i][W - 1 - j]) return 0;
			}
			else cnt++;
		}
		if (cnt == H / 2) return 1;
		return 0;
	}
	for (int i = 0; i < W; i++) {
		if (used[i]) continue;
		used[i] = 1;
		perm[c] = i;
		for (int j = i + 1; j < W; j++) {
			if (used[j]) continue;
			used[j] = 1;
			perm[W - 1 - c] = j;
			if (check(c + 1)) return 1;
			used[j] = 0;
		}
		used[i] = 0;
	}
	return 0;
}
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	if (check(0)) cout << "YES" << endl;
	else cout << "NO" << endl;
}