#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, JC, FC = 0, co = 0, CO = 0;
  string s, c, C, d, D;
  cin >> h >> w;
  for (int i = 1; i <= h; i++) {
    cin >> s;
    JC = 0;
    for (int j = 1; j <= w; j++) {
      if (s[j - 1] != s[j]) {
        JC += 1;
      }
      if (JC == w - 1) {
        FC += 1;
      }
    }
    c = s[0];
    C = s[1];
    if (i > 1) {
      if (c == d) {
        co++;
      } else if (C == D) {
        CO++;
      }
    }
    d = c;
    D = C;
  }
  if (FC == h) {
    cout << "No" << endl;
  } else if (FC != h || co == h - 1 || CO == h - 1) {
    cout << "Yes" << endl;
  }
  return 0;
}
