#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
const long long MOD = 1000000007;
int dx[8] = {1, -1, 0, 0, 1, -1, 1, -1}, dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int n, m, vis[55][55], ans;
char grid[55][55];
void dfs(int r, int c, int pr, int pc, char cur) {
  if (vis[r][c] == 1) ans = 1;
  if (ans) return;
  vis[r][c] = 1;
  for (int i = 0; i < 4; i++) {
    int nx = r + dx[i];
    int ny = c + dy[i];
    if (grid[nx][ny] == cur) {
      if (vis[nx][ny] != 2) {
        if (!((nx == pr) && (ny == pc))) {
          dfs(nx, ny, r, c, cur);
        }
      }
    }
  }
  vis[r][c] = 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j]) {
        dfs(i, j, -1, -1, grid[i][j]);
      }
    }
  }
  if (ans)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
