#include <bits/stdc++.h>
using namespace std;
const int M = 1e8;
int n, m, k, dots = 0, cou = 0;
vector<string> v;
int vis[52][52];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
vector<vector<pair<int, int>>> par(50, vector<pair<int, int>>(50, {-1, -1}));
int isval(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }
void dfs(int x, int y) {
  if (vis[x][y]) {
    cout << "Yes";
    exit(0);
  }
  vis[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    if (isval(x + dx[i], y + dy[i]) && v[x][y] == v[x + dx[i]][y + dy[i]] &&
        (!(par[x][y].first == x + dx[i] && par[x][y].second == y + dy[i]))) {
      par[x + dx[i]][y + dy[i]] = {x, y};
      dfs(x + dx[i], y + dy[i]);
    }
  }
  vis[x][y] = 0;
  par[x][y] = {-1, -1};
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int i, lim, q, p, f = 0, mn = INT_MAX, mx = INT_MIN, j, x, y, t, sum = 0,
                    val = 0;
  cin >> n >> m;
  v.resize(n);
  for (i = 0; i < n; i++) cin >> v[i];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      dfs(i, j);
    }
  }
  cout << "No";
}
