#include <bits/stdc++.h>
using namespace std;
string shuzu[110];
bool non_repeat(string a) {
  for (int i = 1; i < a.length(); i++) {
    if (a[i] != a[i - 1]) {
      return true;
    }
  }
  return false;
}
int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < a; i++) {
    cin >> shuzu[i];
  }
  for (int i = 0; i < a - 1; i++) {
    if (shuzu[i][0] == shuzu[i + 1][0]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = 0; i < a; i++) {
    if (non_repeat(shuzu[i])) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}
