#include <bits/stdc++.h>
using namespace std;
const int N = 55;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
char mat[N][N];
bool vis[N][N];
int n, m;
bool valid(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
bool dfs(int x, int y, int px, int py) {
  bool cycle = false;
  vis[x][y] = true;
  for (int k = 0; k < 4; k++) {
    int nx = x + dx[k];
    int ny = y + dy[k];
    if (!valid(nx, ny)) {
      continue;
    }
    if (nx == px && ny == py) {
      continue;
    }
    if (mat[nx][ny] == mat[x][y]) {
      if (vis[nx][ny]) {
        cycle = true;
      } else {
        cycle |= dfs(nx, ny, x, y);
      }
    }
  }
  return cycle;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      cin >> mat[x][y];
    }
  }
  bool cycle = false;
  for (int x = 0; x < n; x++) {
    for (int y = 0; y < m; y++) {
      if (!vis[x][y]) {
        cycle |= dfs(x, y, -1, -1);
      }
    }
  }
  cout << (cycle ? "Yes" : "No") << '\n';
  return 0;
}
