#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<char>> v;
bool Mastervis[50][50];
bool vis[50][50];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
bool isCyc(int r, int c, int pr, int pc) {
  if (vis[r][c]) return true;
  vis[r][c] = true;
  Mastervis[r][c] = true;
  int nr, nc;
  for (int k = 0; k < 4; k++) {
    nr = r + dy[k];
    nc = c + dx[k];
    if (nr >= 0 && nr < N && nc >= 0 && nc < M && !(nr == pr && nc == pc)) {
      if (v[r][c] == v[nr][nc]) {
        if (isCyc(nr, nc, r, c)) return true;
      }
    }
  }
  return false;
}
int main() {
  string s;
  cin >> N >> M;
  v.resize(N);
  memset(Mastervis, false, 50 * 50 * sizeof(bool));
  for (int i = 0; i < N; i++) {
    cin >> s;
    for (int j = 0; j < M; j++) {
      v[i].push_back(s[j]);
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (!Mastervis[i][j]) {
        memset(vis, false, 50 * 50 * sizeof(bool));
        if (isCyc(i, j, -2, -2)) {
          cout << "Yes";
          return 0;
        }
      }
    }
  }
  cout << "No";
  return 0;
}
