#include <bits/stdc++.h>
using namespace std;
const int Nmax = 200010;
int main() {
  int H, W, flag = 0;
  char s[50][50], a;
  cin >> H >> W;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 1; i < H - 1; i++) {
    for (int j = 1; j < W - 1; j++) {
      a = s[i][j];
      if (s[i - 1][j] != a && s[i + 1][j] != a && s[i][j - 1] != a &&
          s[i][j + 1] != a)
        flag = 1;
    }
  }
  if (s[0][0] != s[0][1] && s[1][0]) flag = 1;
  if (s[0][W] != s[0][W - 1] && s[1][W]) flag = 1;
  if (s[H][0] != s[H - 1][0] && s[H][1]) flag = 1;
  if (s[H][W] != s[H - 1][W] && s[H][W - 1]) flag = 1;
  if (flag == 1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
