#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 19;

char s[N][N];
int p[N];
long long x[N];
long long rx[N];
bool used[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (mask >> i & 1) {
        ++cnt;
      }
    }
    if (cnt != (n + 1) / 2) {
      continue;
    }
    vector<int> a, b;
    for (int i = 0; i < n; ++i) {
      if (mask >> i & 1) {
        a.push_back(i);
      } else {
        b.push_back(i);
      }
    }
    for (int i = 0; i < (n + 1) / 2; ++i) {
      p[i] = i;
    }
    do {
      for (int j = 0; j < m; ++j) {
        x[j] = 0;
        rx[j] = 0;
        used[j] = false;
        long long z = 1;
        for (int i = 0; i < n / 2; ++i) {
          x[j] += (s[a[p[i]]][j] - 'a') * z;
          x[j] += (s[b[i]][j] - 'a') * z * 26;
          rx[j] += (s[b[i]][j] - 'a') * z;
          rx[j] += (s[a[p[i]]][j] - 'a') * z * 26;
          z *= 26 * 26;
        }
        if (n % 2 == 1) {
          x[j] += (s[a[p[n / 2]]][j] - 'a') * z;
          rx[j] += (s[a[p[n / 2]]][j] - 'a') * z;
        }
        for (int i = 0; i < j; ++i) {
          if (!used[i] && rx[i] == x[j]) {
            used[i] = true;
            used[j] = true;
            break;
          }
        }
      }
      int rem = 0;
      for (int i = 0; i < m; ++i) {
        if (!used[i]) {
          ++rem;
        }
      }
      if (rem == m % 2) {
        puts("YES");
        return 0;
      }
    } while (next_permutation(p, p + (n + 1) / 2));
  }
  puts("NO");
}
