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;

bool ans;
int H, W;
vector<bool> used;
vector<int> mrr;
vector<string> S;

bool same(int l, int r) {
  for (int k = 0; k < H; ++k) {
    if (S[k][l] != S[mrr[k]][r]) return false;
  }
  return true;
}

void solve() {
  int isOdd = W % 2;
  used = vector<bool>(W, false);
  for (int i = 0; i < W; ++i) {
    for (int j = i + 1; j < W; ++j) {
      if (used[i] || used[j]) continue;
      if (same(i, j)) used[i] = used[j] = true;
    }
  }
  for (int i = 0; i < W; ++i) {
    if (used[i]) continue;
    if (!isOdd || !same(i, i)) return;
    used[i] = true;
    isOdd = 0;
  }
  ans = true;
}

void dfs(int n, int isOdd) {
  if (ans) return;
  if (n > H - 1) {
    solve();
    return;
  }
  if (mrr[n] != -1) {
    dfs(n + 1, isOdd);
    return;
  }
  if (isOdd) {
    mrr[n] = n;
    dfs(n + 1, 0);
  }
  for (int i = n + 1; i < H; ++i) {
    if (mrr[i] == -1) {
      mrr[n] = i;
      mrr[i] = n;
      dfs(n + 1, isOdd);
      mrr[i] = -1;
    }
  }
  mrr[n] = -1;
}


int main() {
  cin >> H >> W;
  S = vector<string>(H);
  for (int i = 0; i < H; ++i) cin >> S[i];
  mrr = vector<int>(H, -1);
  dfs(0, H % 2);
  cout << ( (ans) ? "YES" : "NO" ) << endl;
  return 0;
}
