#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[2500];
  int x;
  int y;
  int t = 0;
  cin >> x >> y;
  for (int i = 1; i <= x * y; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= x * y; i++) {
    if (y * (x - 1) + 1 > i > y && a[i] != a[i + y] && a[i] != a[i + 1] &&
        a[i] != a[i - 1] && a[i] != a[i - y]) {
      t = 1;
    }
    if (a[1] != a[2] && a[1] != a[1 + y]) {
      t = 1;
    }
    if (a[y] != a[y - 1] && a[y] != a[2 * y]) {
      t = 1;
    }
    if (y * (x - 1) < i < x * y && a[i] != a[i - 1] && a[i] != a[i + 1] &&
        a[i] != a[i - y]) {
      t = 1;
    }
    if (a[y * (x - 1) + 1] != a[y * (x - 1) + 1 - y] &&
        a[y * (x - 1) + 1] != a[y * (x - 1) + 2]) {
      t = 1;
    }
    if (a[x * y] != a[x * y - 1] && a[x * y - y]) {
      t = 1;
    }
    if (1 < i < y && a[i] != a[i - 1] && a[i] != a[i + 1] && a[i] != a[i + y]) {
      t = 1;
    } else {
      t = 2;
    }
  }
  if (t == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  system("pause");
}
