#include <bits/stdc++.h>
using namespace std;
int n, m;
const int maxN = 50, maxM = maxN;
string grid[maxN];
bool visited[maxN][maxM];
bool visited2[maxN][maxM];
bool isValid(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < m) return true;
  return false;
}
void dfs(int x, int y, char ch, int px, int py) {
  visited[x][y] = true;
  int xs[] = {0, 0, 1, -1};
  int ys[] = {1, -1, 0, 0};
  for (int i = 0; i < 4; ++i) {
    int nextX = x + xs[i], nextY = y + ys[i];
    if (isValid(nextX, nextY) && (nextX != px || nextY != py) &&
        visited[nextX][nextY] && !visited2[nextX][nextY]) {
      cout << "Yes";
      exit(0);
    }
    if (isValid(nextX, nextY) && !visited[nextX][nextY] &&
        grid[nextX][nextY] == ch) {
      dfs(nextX, nextY, ch, x, y);
    }
  }
  visited2[x][y] = true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> grid[i];
  for (int x = 0; x < n; ++x) {
    for (int y = 0; y < m; ++y) {
      if (!visited[x][y]) {
        dfs(x, y, grid[x][y], -1, -1);
      }
    }
  }
  cout << "No";
}
