#include <bits/stdc++.h>
using namespace std;
const long long N = 1000;
bool fg[55][55];
long long n, m, dy[4] = {1, 0, -1, 0}, dx[4] = {0, 1, 0, -1};
bool flag;
char s[55][55];
void dfs(long long x, long long y, long long st, long long ed) {
  fg[x][y] = true;
  for (long long i = 0; i < 4; i++) {
    long long a = x + dx[i], b = y + dy[i];
    if (a >= 1 && a <= n && b >= 1 && b <= m && s[a][b] == s[x][y] &&
        (st != a || ed != b)) {
      if (fg[a][b]) {
        flag = true;
        break;
      }
      dfs(a, b, x, y);
    }
  }
}
signed main() {
  memset(fg, false, sizeof fg);
  cin >> n >> m;
  flag = false;
  for (long long i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      if (!fg[i][j]) {
        fg[i][j] = true;
        dfs(i, j, i, j);
        if (flag) break;
      }
    }
    if (flag) break;
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
