#include <bits/stdc++.h>
using namespace std;
long long int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
long long int visited[55][55], flag;
char a[55][55];
long long int n, m;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second > b.second);
}
vector<int> adj[200004];
int depth[200004];
vector<int> diff;
int dfs(int node, int par) {
  int depth[200004];
  vector<int> diff;
  int sub = 0;
  depth[node] = depth[par] + 1;
  for (auto v : adj[node]) {
    if (v == par) continue;
    sub += 1 + dfs(v, node);
  }
  diff.push_back(depth[node] - sub);
  return sub;
}
void dfss(long long int x, long long int y, long long int px, long long int py,
          char col) {
  long long int nx, ny;
  if (x < 0 || x >= n || y < 0 || y >= m || a[x][y] != col) return;
  if (visited[x][y]) {
    flag = 1;
    return;
  }
  visited[x][y] = 1;
  for (long long int i = 0; i < 4; i++) {
    nx = x + dx[i];
    ny = y + dy[i];
    if (nx == px && ny == py) continue;
    dfss(nx, ny, x, y, col);
  }
}
int main() {
  long long int i, j;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (!visited[i][j]) dfss(i, j, -1, -1, a[i][j]);
    }
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
}
