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 pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 29
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



int h,w;
string s[12];
ll c =0;

bool rev(char l[], char t[]){
  REP(i,w){
    if(l[i] != t[w-1-i]){
      return false;
    }
  }
  return true;
}

bool ok(vector<pii> p){
  char t[12][13];
  c++;
  REP(i,p.size()){
    int f = p[i].first;
    int b = p[i].second;
    REP(j,h){
      t[j][i] = s[j][f];
      t[j][w-1-i] = s[j][b];
    }
  }
  bool used[12];
  REP(i,h) used[i] = false;
  int cnt = 0;
  REP(i,h){
    FOR(j,i+1,h){
      if(used[i]) break;
      if(rev(t[i],t[j])){
        used[i] = true;
        used[j] = true;
        cnt += 2;
      }
    }
  }
  if(h-cnt>1) return false;
  if(h-cnt==0) return true;
  REP(i,h){
    if(used[i]) continue;
    return rev(t[i],t[i]);
  }
}

bool dfs(vector<bool> used, vector<pii> p){
  if(p.size()*2 == w){
    return ok(p);
  }
  if(p.size()*2+1==w){
    vector<pii> tmp = p;
    REP(i,w){
      if(used[i]) continue;
      tmp.push_back(pii(i,i));
      break;
    }
    return ok(tmp);
  }
  REP(i,w){
    if(used[i]) continue;
    vector<bool> tmp_u = used;
    tmp_u[i] = true;
    FOR(j,i+1,w){
      if(tmp_u[j]) continue;
      vector<pii> tmp = p;
      vector<bool> tmp_uu = tmp_u;
      tmp_uu[j] = true;
      tmp.push_back(pii(i,j));
      if(dfs(tmp_uu,tmp)){
        return true;
      }
    }
    if(w >= 12)break;
  }
  return false;
}


int main(){
  cin >> h >> w;
  REP(i,h) cin >> s[i];
  vector<bool> used;
  REP(i,w) used.push_back(false);
  vector<pii> p;
  if(dfs(used, p)){
    cout << "YES" <<endl;
  }else{
    cout << "NO" << endl;
  }
  //cout << c << endl;
}
