#include <bits/stdc++.h>
using namespace std;
vector<char> used;
bool res = false;
void dfs(const vector<vector<long long> >& graf, long long v, long long p) {
  used[v] = 1;
  for (auto u : graf[v]) {
    if (!used[u]) {
      dfs(graf, u, v);
    } else {
      if (u != p) {
        res = 1;
      }
    }
  }
}
void solve() {
  long long Q;
  Q = 1;
  while (Q--) {
    long long n, m;
    cin >> n >> m;
    vector<vector<char> > a(n, vector<char>(m));
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < m; ++j) {
        cin >> a[i][j];
      }
    }
    const vector<pair<long long, long long> > dir{
        {-1, 0}, {1, 0}, {0, -1}, {0, 1}};
    vector<vector<long long> > graf(n * m, vector<long long>());
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < m; ++j) {
        for (auto p : dir) {
          long long ni = i + p.first;
          long long nj = j + p.second;
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
          if (a[i][j] == a[ni][nj]) {
            graf[m * i + j].push_back(m * ni + nj);
          }
        }
      }
    }
    for (long long i = 0; i < n; ++i) {
      for (long long j = 0; j < m; ++j) {
        used.assign(n * m, 0);
        dfs(graf, m * i + j, -1);
      }
    }
    if (res) {
      cout << "Yes";
    } else {
      cout << "No";
    }
  }
}
signed main(signed argc, char** argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (argc > 1 && (string)argv[1] == "local") {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    solve();
    while (cin.peek() != EOF) {
      if (isspace(cin.peek()))
        cin.get();
      else {
        cout << '\n';
        solve();
      }
    }
  } else {
    solve();
  }
}
