#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string s[50];
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int cur = s[i][j];
      map<pair<int, int>, char> used;
      queue<pair<int, int> > q;
      used[make_pair(i, j)] = true;
      q.push(make_pair(i, j));
      queue<pair<int, int> > parent;
      parent.push(make_pair(i, j));
      while (!q.empty()) {
        pair<int, int> v = q.front();
        pair<int, int> p = parent.front();
        q.pop();
        parent.pop();
        pair<int, int> t1 = v;
        if (t1.second < m - 1) {
          t1.second++;
          if (used[t1] && t1 != p) {
            cout << "Yes";
            return 0;
          }
          if (!used[t1] && s[t1.first][t1.second] == cur) {
            used[t1] = true;
            q.push(t1);
            parent.push(v);
          }
        }
        t1 = v;
        if (t1.second > 0) {
          t1.second--;
          if (used[t1] && t1 != p) {
            cout << "Yes";
            return 0;
          }
          if (!used[t1] && s[t1.first][t1.second] == cur) {
            used[t1] = true;
            q.push(t1);
            parent.push(v);
          }
        }
        t1 = v;
        if (t1.first < n - 1) {
          t1.first++;
          if (used[t1] && t1 != p) {
            cout << "Yes";
            return 0;
          }
          if (!used[t1] && s[t1.first][t1.second] == cur) {
            used[t1] = true;
            q.push(t1);
            parent.push(v);
          }
        }
        t1 = v;
        if (t1.first > 0) {
          t1.first--;
          if (used[t1] && t1 != p) {
            cout << "Yes";
            return 0;
          }
          if (!used[t1] && s[t1.first][t1.second] == cur) {
            used[t1] = true;
            q.push(t1);
            parent.push(v);
          }
        }
      }
    }
  }
  cout << "No";
  return 0;
}
