#include <bits/stdc++.h>
using namespace std;
string a[50];
int n, m, vis[50][50], go[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
bool cir;
void dfs(int i, int j, char col, int lx, int ly) {
  if (col != a[i][j] || vis[i][j] == 2) return;
  if (vis[i][j] == 1) {
    cir = 1;
    return;
  }
  vis[i][j] = 1;
  for (int k = 0; k < 4; k++) {
    int x = i + go[k][0];
    int y = j + go[k][1];
    if (x >= 0 && x < n && y >= 0 && y < m && (x != lx || y != ly))
      dfs(x, y, a[i][j], i, j);
  }
  vis[i][j] = 2;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dfs(i, j, a[i][j], i, j);
    }
  }
  if (cir) {
    cout << "Yes";
  } else
    cout << "No";
  return 0;
}
