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