#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[55][55];
bool used[60][60];
bool dfs(int x, int y, pair<int, int> prev) {
  used[x][y] = 1;
  for (pair<int, int> to : g[x][y]) {
    if (to == prev) continue;
    if (used[to.first][to.second]) return 1;
    if (dfs(to.first, to.second, {x, y})) return 1;
  }
  used[x][y] = 0;
  return 0;
}
void init() {
  for (int i = 0; i < 60; i++) {
    for (int j = 0; j < 60; j++) {
      used[i][j] = 0;
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  char c[n][m];
  int ok = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      if (j && c[i][j] == c[i][j - 1]) {
        g[i][j].push_back({i, j - 1});
        g[i][j - 1].push_back({i, j});
      }
      if (i && c[i][j] == c[i - 1][j]) {
        g[i][j].push_back({i - 1, j});
        g[i - 1][j].push_back({i, j});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      init();
      if (dfs(i, j, {-1, -1})) {
        ok = 1;
        break;
      }
    }
    if (ok) break;
  }
  if (ok)
    cout << "Yes\n";
  else
    cout << "No\n";
}
