#include <bits/stdc++.h>
int main() {
  int n, m, i, j, f = 0, ff = 0;
  scanf("%d %d", &n, &m);
  char a[n][m + 5];
  for (i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  char c;
  for (i = 0; i < n; i++) {
    c = a[i][0];
    for (j = 0; j < m; j++) {
      if (a[i][j] != c) {
        ff = 1;
        break;
      }
    }
  }
  for (i = 1; i < n; i++) {
    if (strcmp(a[i], a[i - 1]) == 0) f = 1;
  }
  if (f == 1 || ff == 1)
    printf("No\n");
  else
    printf("Yes\n");
}
