#include <bits/stdc++.h>
using namespace std;
const int INF = 0x4f4f4f4f;
const double eps = 1e-6;
const long double PI = acos(0.0) * 2.0;
const int N = 10000 + 10;
int pre[N];
int _rank[N];
char maze[N][N];
int find(int x);
int join(int x, int y);
void ini(void);
int same(int x, int y);
int main() {
  ini();
  int n, m;
  scanf("%d%d%*c", &n, &m);
  for (int i = 0; i < n; i++) gets(maze[i]);
  bool ok = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (maze[i][j] == maze[i + 1][j] && i < n - 1) {
        if (same(i * m + j, (i + 1) * m + j)) {
          puts("Yes");
          return 0;
        } else
          join(i * m + j, (i + 1) * m + j);
      }
      if (maze[i][j] == maze[i][j + 1] && j < m - 1) {
        if (same(i * m + j, i * m + j + 1)) {
          puts("Yes");
          return 0;
        } else
          join(i * m + j, i * m + j + 1);
      }
    }
  }
  puts("No");
  return 0;
}
void ini(void) {
  int i;
  for (i = 0; i < N; i++) pre[i] = i, _rank[i] = 0;
}
int join(int x, int y) {
  int fx = find(x), fy = find(y);
  if (fx == fy) return 0;
  if (_rank[fx] > _rank[fy]) {
    pre[fy] = fx;
  } else {
    pre[fx] = fy;
    if (_rank[fx] == _rank[fy]) _rank[fy]++;
  }
}
int find(int x) {
  int r = x;
  while (r != pre[r]) r = pre[r];
  int i = x, j;
  while (r != pre[i]) {
    j = pre[i];
    pre[i] = r;
    i = j;
  }
  return r;
}
int same(int x, int y) { return find(x) == find(y); }
