#include <bits/stdc++.h>
using namespace std;
int popcount(unsigned int x) {
  x -= x >> 1 & 0x55555555;
  x = (x & 0x33333333) + (x >> 2 & 0x33333333);
  x = x + (x >> 4) & 0x0F0F0F0F;
  return x * 0x01010101 >> 24;
}
int tzcnt(unsigned int x) { return popcount(~x & x - 1); }
struct Point {
  int x, y;
  Point(int p, int q) : x(p), y(q) {}
};
string paint[50];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  for (int i = 0; i < H; ++i) {
    cin >> paint[i];
  }
  bool yes = true;
  const int dirh[] = {-1, 0, 0, 1};
  const int dirw[] = {0, -1, 1, 0};
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      char t = paint[i][j];
      for (int k = 0; k < 4; ++k) {
        if (0 <= i + dirh[k] && i + dirh[k] < H && 0 <= j + dirw[k] &&
            j + dirw[k] < W) {
          if (t == paint[i + dirh[k]][j + dirw[k]]) {
            goto suc;
          }
        }
      }
      yes = false;
      goto fail;
    suc:;
    }
  }
fail:
  cout << (yes ? "Yes" : "No") << "\n";
  int aaa;
  cin >> aaa;
}
