#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > graph;
vector<bool> vis;
vector<int> parent;
int flag;
void dfsvisit(int s) {
  vis[s] = true;
  for (int i = 0; i < graph[s].size(); i++) {
    if (!vis[graph[s][i]]) {
      parent[graph[s][i]] = s;
      dfsvisit(graph[s][i]);
    } else if (graph[s][i] != parent[s]) {
      flag = 1;
    }
  }
}
int main() {
  int n, m, i, j;
  cin >> n >> m;
  char s[n + 1][m + 1];
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> s[i][j];
    }
  }
  graph.resize(3000);
  vis.resize(3000);
  parent.resize(3000);
  int t;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      t = (i - 1) * m + j;
      if (i - 1 >= 1 && s[i][j] == s[i - 1][j]) {
        graph[t].push_back(t - m);
      }
      if (i + 1 <= n && s[i][j] == s[i + 1][j]) {
        graph[t].push_back(t + m);
      }
      if (j - 1 >= 1 && s[i][j] == s[i][j - 1]) {
        graph[t].push_back(t - 1);
      }
      if (j + 1 <= m && s[i][j] == s[i][j + 1]) {
        graph[t].push_back(t + 1);
      }
    }
  }
  fill_n(vis.begin(), 3000, false);
  fill_n(parent.begin(), 3000, 0);
  flag = 0;
  for (i = 1; i <= n * m; i++) {
    if (!vis[i]) {
      dfsvisit(i);
    }
  }
  if (flag) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
