#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m;
bool cycle = false;
string colors[55];
bool visited[55][55];
long long diffx[] = {1, -1, 0, 0};
long long diffy[] = {0, 0, 1, -1};
void dfs(long long x, long long y, long long fromX, long long fromY, char col) {
  if (x < 0 || x >= n || y < 0 || y >= m) return;
  if (colors[x][y] != col) return;
  if (visited[x][y]) {
    cycle = true;
    return;
  }
  visited[x][y] = true;
  for (long long k = 0; k < 4; k++) {
    long long nextx = x + diffx[k];
    long long nexty = y + diffy[k];
    if (nextx == fromX && nexty == fromY) continue;
    dfs(nextx, nexty, x, y, col);
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    cin >> colors[i];
  }
  memset(visited, false, sizeof(visited));
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (!visited[i][j]) dfs(i, j, -1, -1, colors[i][j]);
    }
  }
  cout << (cycle ? "Yes" : "No") << "\n";
  return 0;
}
