#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<char>> v(51, vector<char>(51, '0'));
set<pair<int, int>> ss;
bool ret = false;
void game(int x, int y, int px, int py) {
  if (ss.count({x, y})) {
    ret = true;
    return;
  }
  ss.insert({x, y});
  if (y < m - 1 && v[x][y] == v[x][y + 1] && (y + 1 != py || px != x)) {
    game(x, y + 1, x, y);
  }
  if (y && v[x][y] == v[x][y - 1] && (y - 1 != py || px != x)) {
    game(x, y - 1, x, y);
  }
  if (x + 1 < n && v[x][y] == v[x + 1][y] && (x + 1 != px || py != y)) {
    game(x + 1, y, x, y);
  }
  if (x && v[x][y] == v[x - 1][y] && (x - 1 != px || py != y)) {
    game(x - 1, y, x, y);
  }
}
int main() {
  cin >> n >> m;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      char c;
      cin >> c;
      v[i][j] = c;
    }
  }
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      game(i, j, i, j);
      ss.clear();
      if (ret) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No" << endl;
}
