#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (b == 0) ? a : gcd(b, a % b);
}
vector<string> t;
int vis[55][55];
int n, m;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool isValid(int x, int y) {
  if (x < 0 || x >= n || y < 0 || y >= m) return false;
  return true;
}
bool ans = false;
void dfs(int x, int y, int xp, int yp, char c) {
  if (isValid(x, y) == false) return;
  if (t[x][y] != c) return;
  if (vis[x][y] == 1) {
    ans = true;
    return;
  }
  vis[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int X = x + dx[i];
    int Y = y + dy[i];
    if (X == xp && Y == yp) continue;
    dfs(X, Y, x, y, c);
  }
}
int main() {
  long long int T = 1;
  while (T--) {
    cin >> n >> m;
    t.clear();
    for (int i = 0; i <= n - 1; i++) {
      string a;
      cin >> a;
      t.push_back(a);
    }
    for (int i = 0; i <= n - 1; i++)
      for (int j = 0; j <= m - 1; j++) vis[i][j] = 0;
    for (int i = 0; i <= n - 1; i++) {
      for (int j = 0; j <= m - 1; j++) {
        if (vis[i][j] == 0) {
          dfs(i, j, -1, -1, t[i][j]);
          if (ans == true) break;
        }
      }
    }
    if (ans == true)
      cout << "Yes" << '\n';
    else
      cout << "No" << '\n';
  }
  return 0;
}
