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<cstdio>

int h, w;
char grid[12][12+1];

bool solve3(int sy[]) {
	bool used[12];
	for(int i=0;i<h;i++) used[i] = false;
	bool mid_used = h % 2 == 0;
	for(int i=0;i<h;i++) if(!used[i]) {
		bool ok = false;
		for(int j=i+1;j<h;j++) if(!used[j]) {
			bool same = true;
			for(int k=0;k<w;k++) {
				if(grid[i][sy[k]] != grid[j][sy[w-1-k]]) same = false;
			}
			if(same) {
				used[i] = used[j] = true;
				ok = true;
				break;
			}
		}
		if(!ok && !mid_used) {
			bool same = true;
			for(int k=0;k<w/2;k++) {
				if(grid[i][sy[k]] != grid[i][sy[w-1-k]]) same = false;
			}
			if(same) {
				used[i] = true;
				mid_used = true;
				ok = true;
			}
		}
		if(!ok) return false;
	}
	return true;
}

bool solve2(bool used[], int ind, int sy[]) {
	if(w-2*ind <= 1) {
		return solve3(sy);
	} else {
		for(int i=0;i<w;i++) if(!used[i]) {
			sy[ind] = i;
			break;
		}
		used[sy[ind]] = true;
		for(int i=0;i<w;i++) if(!used[i]) {
			used[i] = true;
			sy[w-1-ind] = i;
			if(solve2(used, ind+1, sy)) return true;
			used[i] = false;
		}
		used[sy[ind]] = false;
		return false;
	}
}

bool solve() {
	bool used[12];
	for(int i=0;i<w;i++) used[i] = false;
	int sy[12];
	if(w % 2 == 1) {
		for(int i=0;i<w;i++) {
			used[i] = true;
			sy[w/2] = i;
			if(solve2(used, 0, sy)) return true;
			used[i] = false;
		}
		return false;
	} else {
		return solve2(used, 0, sy);
	}

}

int main() {
	scanf("%d %d", &h, &w);
	for(int i=0;i<h;i++) {
		scanf("%12s", grid[i]);
	}
	printf("%s\n", solve() ? "YES" : "NO");
	return 0;
}
