#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  long rnd = 0;
  string s[50];
  pair<int, int> p, father;
  int x, y, nx, ny;
  bool found = false;
  long v[50][50];
  int ax[] = {-1, 0, 1, 0};
  int ay[] = {0, -1, 0, 1};
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < m; j++) v[i][j] = false;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j]) continue;
      queue<pair<int, int> > fq;
      queue<pair<int, int> > q;
      q.push(make_pair(i, j));
      fq.push(make_pair(i, j));
      v[i][j] = true;
      while (q.size()) {
        p = q.front();
        father = fq.front();
        x = p.first;
        y = p.second;
        q.pop();
        fq.pop();
        for (int k = 0; k < 4; k++) {
          nx = x + ax[k];
          ny = y + ay[k];
          if (nx >= 0 && nx < n && ny >= 0 && ny < m && s[x][y] == s[nx][ny]) {
            if (!v[nx][ny]) {
              q.push(make_pair(nx, ny));
              fq.push(make_pair(x, y));
              v[nx][ny] = true;
            } else if (nx != father.first || ny != father.second) {
              found = true;
              break;
            }
          }
        }
        if (found) break;
      }
      if (found) break;
    }
    if (found) break;
  }
  if (found)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
