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;
using ll = long long;

int h, w;
string s[12];

int qina(vector<int> v) {
  int sole = w % 2;
  int used[12] = {};
  for(int i = 0; i < w; i++) {
    int ok = 0;
    if(used[i]) continue;
    used[i] = 1;
    for(int j = i + 1; j < w; j++) if(!used[j]) {
      int okk = 1;
      for(int k = 0; k < h; k++)
        if(s[v[k]][i] != s[v[h - 1 - k]][j]) { okk = 0; break; }
      if(okk) {
        used[j] = 1;
        ok = 1;
        break;
      }
    }
    if(ok) continue;
    if(sole--) {
      int okk = 1;
      for(int k = 0; k < h; k++)
        if(s[v[k]][i] != s[v[h - 1 - k]][i]) { okk = 0; break; }
      if(!okk) return 0;
      continue;
    }
    return 0;
  }
  return 1;
}

int ecas(int y, int c, vector<int> v, set<int> u) {
  if(y == 0) {
    if(qina(v)) return 1;
    return 0;
  }
  if(y % 2 == 1) {
    for(int i = 0; i < h; i++) {
      auto tv = v;
      auto tu = u;
      tv[h / 2] = i;
      tu.emplace(i);
      if(ecas(y - 1, 0, tv, tu)) return 1;
    }
    return 0;
  }
  int f = 0;
  for(int i = 0; i < h; i++) if(!u.count(i)) { f = i; break; }

  for(int i = 0; i < h; i++) if(!u.count(i) && f != i) {
    auto tv = v;
    auto tu = u;
    tv[c] = f;
    tv[h - 1 - c] = i;
    tu.emplace(f);
    tu.emplace(i);
    if(ecas(y - 2, c + 1, tv, tu)) return 1;
  }
  return 0;
}

int solve() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> h >> w;
  for(int i = 0; i < h; i++) cin >> s[i];
  return ecas(h, 0, vector<int>(h), set<int>());
}

int main() {
  cout << (solve() ? "YES" : "NO") << endl;
}
