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;

char s[15][15];
int n, m;
int nm[15], mm[15], cnt[12][26];
vector<int> g[12];

bool bar(int i, bool self) {
  if(i == m) return true;
  if(self) {
    bool ok = true;
    for(int j=0;j<n;j++) {
      if(s[j][i] == s[nm[j]][i]) continue;
      ok = false;
      break;
    }
    if(ok) {
      mm[i] = i;
      int j = i+1;
      while(mm[j]>=0) j++;
      if(bar(j,false)) return true;
      mm[i] = -1;
    }
  }
  for(int j=i+1;j<m;j++) {
    if(mm[j]>=0) continue;
    bool ok = true;
    for(int k=0;k<n;k++) {
      if(s[k][i] == s[nm[k]][j]) continue;
      ok = false;
      break;
    }
    if(ok) {
      mm[i] = j;
      mm[j] = i;
      int k = i+1;
      while(mm[k]>=0) k++;
      if(bar(k,self)) return true;
      mm[i] = mm[j] = -1;
    }
  }
  return false;
}

bool foo(int i, bool self) {
  if(i == n) return bar(0,m&1);
  if(self) {
    nm[i] = i;
    int j = i+1;
    while(nm[j]>=0) j++;
    if(foo(j,false)) return true;
    nm[i] = -1;
  }
  for(int j : g[i]) {
    if(nm[j]>=0) continue;
    nm[i] = j;
    nm[j] = i;
    int k = i+1;
    while(nm[k]>=0) k++;
    if(foo(k,self)) return true;
    nm[i] = nm[j] = -1;
  }
  return false;
}

int main() {
  scanf("%d%d",&n,&m);
  for(int i=0;i<n;i++) {
    scanf("%s",s[i]);
    for(int j=0;j<m;j++)
      cnt[i][s[i][j]-'a']++;
  }
  for(int i=0;i<n;i++)
    for(int j=i+1;j<n;j++) {
      bool e = true;
      for(int k=0;k<26;k++) {
        if(cnt[i][k] == cnt[j][k]) continue;
        e = false;
        break;
      }
      if(e) g[i].push_back(j);
    }
  memset(nm,-1,sizeof(nm));
  memset(mm,-1,sizeof(mm));
  puts(foo(0,n&1)?"YES":"NO");
}
