#include <bits/stdc++.h>
using namespace std;
int n, m, cycle = 0;
char v[55][55];
int val[50][50] = {0};
int X[4] = {0, 0, 1, -1};
int Y[4] = {1, -1, 0, 0};
void dfs(int x, int y, int px, int py, char c) {
  val[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int xx = x + X[i];
    int yy = y + Y[i];
    if (xx < 0 || yy < 0 || xx >= n || yy >= m) continue;
    if (v[xx][yy] != c) continue;
    if (xx == px && yy == py) continue;
    if (val[xx][yy]) {
      cycle = 1;
      return;
    }
    if (!val[xx][yy]) dfs(xx, yy, x, y, c);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> v[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!val[i][j]) dfs(i, j, -1, -1, v[i][j]);
    }
  }
  if (cycle)
    cout << "Yes";
  else
    cout << "No";
}
