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

int h, w;
char s[13][13];
char ns[13][13];

int p[13];
bool used[13];

bool finished;

void check(){
	for(int i=1; i<=h; i++)
		for(int j=1; j<=w; j++)
			ns[i][j] = s[i][p[j]];


	int cnt=0;
	int chk = 0;
	for(int i=1; i<=h; i++){
		if(chk & (1<<i)) continue;
		bool found=false;
		for(int j=i+1; j<=h; j++){
			if(chk & (1<<j)) continue;
			bool flag=true;
			for(int k=1, l=w; k<=w; k++, l--)
				if(ns[i][k] != ns[j][l]){
					flag=false;
					break;
				}
			if(flag){
				found=true;
				chk |= (1<<i);
				chk |= (1<<j);
				break;
			}
		}
		if(!found) cnt++;
		if((h%2==0 && cnt>0) || (h%2==1 && cnt>1)) return;
	}
	finished = true;
}

void backtrack(int now, int val, int cnt){
	for(int i=val+1; i<=w; i++){
		if(used[i]) continue;
		used[i]=true;
		p[now]=i;

		if(cnt == w){ /// end condition
			check();
		}
		else if(cnt&1) backtrack(w+1-now, i, cnt+1);
		else backtrack(w+2-now, 0, cnt+1);

		used[i]=false;

		if(finished) return;
	}
	return;
}

int main(){
	scanf("%d %d", &h, &w);
	for(int i=1; i<=h; i++){
		scanf("\n");
		for(int j=1; j<=w; j++)
			scanf("%c", &s[i][j]);
	}
	backtrack(1, 0, 1);
	puts(finished?"YES":"NO");
	return 0;
}
