#include <bits/stdc++.h>
using namespace std;
long long n, m;
bool ans = false;
void dfs(vector<vector<char>> &mp, vector<vector<bool>> &visited, long long x,
         long long y, long long px, long long py) {
  if (ans == true) return;
  vector<long long> aa = {0, 0, -1, 1};
  vector<long long> bb = {1, -1, 0, 0};
  for (long long i = 0; i < 4; i++) {
    long long a = x + aa[i];
    long long b = y + bb[i];
    if (a < 0 || a >= n) continue;
    if (b < 0 || b >= m) continue;
    if (a == px && b == py) continue;
    if (mp[a][b] != mp[x][y]) continue;
    if (visited[a][b] == true) {
      ans |= true;
      return;
    }
    visited[a][b] = true;
    dfs(mp, visited, a, b, x, y);
  }
}
int32_t main() {
  cin >> n >> m;
  vector<vector<char>> mp(n, vector<char>(m));
  vector<vector<bool>> visited(n, vector<bool>(m));
  ;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> mp[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (visited[i][j] == true) continue;
      dfs(mp, visited, i, j, i, j);
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
