#include <bits/stdc++.h>
using namespace std;
int main() {
  bool flag = true;
  int n, m;
  cin >> n;
  cin >> m;
  char prev;
  for (int i = 0; i < n; i++) {
    string row;
    cin >> row;
    if (i != 0 && row[0] == prev) {
      flag = false;
    }
    for (int j = 1; j < m; j++) {
      if (row[j] != row[0]) {
        flag = false;
        break;
      }
    }
    prev = row[0];
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
