#include <bits/stdc++.h>
using namespace std;
char a[52][52];
int n, m;
vector<int> g[2500];
int b[2500];
int make(int i, int j) { return i * m + j; }
int dfs(int i, int k, int p = -1) {
  if (b[i] == k) return 1;
  b[i] = k;
  for (int j = 0; j < g[i].size(); j++)
    if (p != g[i][j] && dfs(g[i][j], k, i) == 1) return 1;
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (i && a[i][j] == a[i - 1][j]) {
        int x = make(i, j);
        int y = make(i - 1, j);
        g[x].push_back(y);
        g[y].push_back(x);
      }
      if (j && a[i][j] == a[i][j - 1]) {
        int x = make(i, j);
        int y = make(i, j - 1);
        g[x].push_back(y);
        g[y].push_back(x);
      }
    }
  memset(b, 0, sizeof(b));
  for (int i = 0; i < m * n; i++)
    if (b[i] == 0 && dfs(i, i + 1) == 1) {
      cout << "Yes\n";
      return 0;
    }
  cout << "No\n";
  return 0;
}
