#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, n, m, c;
  string s, ps;
  scanf("%d%d", &n, &m);
  scanf("\n");
  getline(cin, s);
  for (i = 0; i < n; ++i) {
    if (ps == s) {
      printf("NO\n");
      return 0;
    }
    for (j = 0; j < ((int)(s.size())) - 1; ++j) {
      if (s[j] != s[j + 1]) {
        printf("NO\n");
        return 0;
      }
    }
    ps = s;
    getline(cin, s);
  }
  printf("YES\n");
  return 0;
}
