#include <bits/stdc++.h>
using namespace std;
bool min_func(int i, int j) { return (i < j); }
bool max_func(int i, int j) { return (i > j); }
int n, m;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int mat[51][51];
int visited[51][51];
int flag = 0;
void DFS(int x, int y, int sx, int sy, int color) {
  if (x < 1 || x > n || y < 1 || y > m) {
    return;
  }
  if (visited[x][y] && mat[x][y] == color) {
    flag = 1;
    return;
  }
  visited[x][y] = 1;
  for (int i = 0; i < 4; ++i) {
    int px = x + dx[i];
    int py = y + dy[i];
    if (px == sx && py == sy) {
      continue;
    } else if (mat[px][py] == color) {
      DFS(px, py, x, y, color);
    }
  }
}
int main() {
  memset((mat), -1, sizeof(mat));
  memset((visited), 0, sizeof(visited));
  int px, py;
  char c;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c;
      mat[i][j] = c - 'A';
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (!visited[i][j]) {
        DFS(i, j, -1, -1, mat[i][j]);
      }
    }
  }
  cout << (flag ? "Yes" : "No") << endl;
  return 0;
}
