#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  for (int i = 0; i < h; i++) {
    cin >> v[i];
  }
  int fl = 0, ff = 0;
  bool isno = false;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      fl = 0;
      ff = 0;
      if (j + 1 < w) {
        ff++;
        if (v[i][j] != v[i][j + 1]) {
          fl++;
        }
      }
      if (j - 1 >= 0) {
        ff++;
        if (v[i][j] != v[i][j - 1]) {
          fl++;
        }
      }
      if (i + 1 < h) {
        ff++;
        if (v[i][j] != v[i + 1][j]) {
          fl++;
        }
      }
      if (i - 1 >= 0) {
        ff++;
        if (v[i][j] != v[i - 1][j]) {
          fl++;
        }
      }
      if (fl == ff) {
        break;
      }
    }
  }
  if (fl == ff) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
