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 <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
/**==Info==
*Program:2
*Problem:Symmetric Grid
*Date:2018-4-21
*Algorithm:latte's Solution
*Stats:Unknown*/

bool debug=false;

int n,m;
string s[15];
string t[15];

void func(){
	map<string,int> cnt;
	for(int i=0;i<m;i++){
		string s="";
		for(int j=0;j<n;j++){
			if(t[j][i]=='*'){
				s+=t[n-1-j][i];
			}else{
				s+=t[j][i];
			}
		}
		
		string ano=s;
		reverse(ano.begin(),ano.end());
		if(ano>=s){
			cnt[s]++;
		}else{
			cnt[ano]--;
		}
	}
	
	bool odd=false;
	for(map<string,int>::iterator it=cnt.begin();it!=cnt.end();it++){
		if(it->second==0) continue;
		string a=it->first;
		string b=a;
		reverse(b.begin(),b.end());
		
		if(a!=b) return;
		if(it->second%2==0) continue;
		if(odd) return;
		odd=true;
	}
	
	puts("YES");
	exit(0);
}
void dfs(int mask,int pos){
	if(mask==0){
		func();
		return;
	}
	
	int p=0;
	while(~mask>>p&1){
		p++;
	}
	
	t[pos]=s[p];
	for(int i=p+1;i<n;i++){
		if((mask>>i)&1){
			t[n-1-pos]=s[i];
			
			dfs(mask^(1<<p)^(1<<i),pos+1);
		}	
	}
}
int main(int argc,char* argv[]){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	
	if(n%2==1){
		s[n]=string(m,'*');
		n++;
	}
	
	dfs((1<<n)-1,0);
	
	puts("NO");
	return 0;
}

