#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
int n, m;
bool Vis[51][51], is;
char grid[51][51];
int Dx[] = {-1, 0, 1, 0};
int Dy[] = {0, 1, 0, -1};
bool check(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
void dfs(int x, int y, int px, int py) {
  Vis[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int nx = x + Dx[i];
    int ny = y + Dy[i];
    if (check(nx, ny) && grid[nx][ny] == grid[x][y]) {
      if (!Vis[nx][ny]) {
        dfs(nx, ny, x, y);
      } else {
        if ((nx != px) || (ny != py)) {
          is = 1;
          return;
        }
      }
    }
  }
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) grid[i][j] = s[j];
  }
  for (int i = 0; i < n && !is; i++) {
    for (int j = 0; j < m && !is; j++) {
      if (!Vis[i][j]) dfs(i, j, i, j);
    }
  }
  cout << (is ? "Yes" : "No");
}
int main() {
  int t;
  t = 1;
  while (t--) {
    solve();
    cout << "\n";
    ;
  }
  return 0;
}
