#include <bits/stdc++.h>
using namespace std;
int m, n;
char a[55][55];
bool visited[55][55];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int newX, newY, bestX, bestY, finalX, finalY;
bool flag;
int cnt;
bool check(int a, int b) {
  if (a > 0 && a <= m && b > 0 && b <= n) return true;
  return false;
}
void dfs(int i, int j, int pX, int pY) {
  if (visited[i][j]) return;
  int u, v;
  for (int k = 0; k < 4; k++) {
    u = i + dx[k];
    v = j + dy[k];
    if (a[u][v] == a[i][j]) {
      if (visited[u][v] && (u != pX || v != pY)) {
        flag = true;
      } else {
        visited[i][j] = true;
        dfs(u, v, i, j);
      }
    }
  }
}
int main() {
  cin >> m >> n;
  memset(a, '$', sizeof a);
  for (int i = 1; i <= m; i++) cin >> a[i];
  flag = false;
  for (int i = 1; i <= m; i++) {
    for (int j = 1; j <= n; j++) {
      memset(visited, false, sizeof visited);
      dfs(i, j, 0, 0);
    }
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
