#include <bits/stdc++.h>
using namespace std;
char str[1000][1000];
long long mark[1000][1000];
long long n, m;
long long bfs(long long s, long long t) {
  long long flag = 0;
  queue<pair<long long, long long> > q;
  q.push(make_pair(s, t));
  while (!q.empty()) {
    pair<long long, long long> p = q.front();
    long long a = p.first;
    long long b = p.second;
    q.pop();
    if (mark[a][b] == 1) {
      flag = 1;
      break;
    }
    mark[a][b] = 1;
    char ch = str[a][b];
    if ((a + 1) < n) {
      if (str[a + 1][b] == ch && !mark[a + 1][b]) {
        q.push(make_pair(a + 1, b));
      }
    }
    if ((a - 1) >= 0) {
      if (str[a - 1][b] == ch && !mark[a - 1][b]) {
        q.push(make_pair(a - 1, b));
      }
    }
    if ((b + 1) < m) {
      if (str[a][b + 1] == ch && !mark[a][b + 1]) {
        q.push(make_pair(a, b + 1));
      }
    }
    if ((b - 1) >= 0) {
      if (str[a][b - 1] == ch && !mark[a][b - 1]) {
        q.push(make_pair(a, b - 1));
      }
    }
  }
  if (flag) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  long long i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      mark[i][j] = 0;
    }
  }
  long long flag = 0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (!mark[i][j]) {
        if (bfs(i, j)) {
          flag = 1;
          break;
        }
      }
    }
    if (flag == 1) {
      break;
    }
  }
  if (flag == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
