#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > v(1000);
vector<int> vis(1000);
int n, m;
bool dfs(int node, int par) {
  vis[node] = 1;
  for (int i = 0; i < v[node].size(); i++) {
    int child = v[node][i];
    if (vis[child] == 0) {
      if (dfs(child, node)) return true;
    } else if (child != par && vis[child] == 1)
      return true;
  }
  vis[node] = -111;
  return false;
}
int main() {
  cin >> n >> m;
  string c[100];
  for (int i = 0; i < n; i++) cin >> c[i];
  v.resize(n * m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i + 1 < n && c[i][j] == c[i + 1][j]) {
        v[i * m + j].push_back((i + 1) * m + j);
        v[(i + 1) * m + j].push_back(i * m + j);
      }
      if (j + 1 < m && c[i][j] == c[i][j + 1]) {
        v[i * m + j].push_back(i * m + j + 1);
        v[i * m + j + 1].push_back(i * m + j);
      }
    }
  }
  vis.reserve(n * m);
  for (int i = 0; i < n * m; i++) vis[i] = 0;
  for (int i = 0; i < m * n; i++)
    if (dfs(i, -9)) {
      cout << "Yes";
      return 0;
    }
  cout << "No";
  return 0;
}
