#include <bits/stdc++.h>
using namespace std;
char arr[51][51];
bool visited[51][51];
int n, m, icount = 0, a, b;
bool found = false;
char now;
int dx[] = {0, 1, -1, 0};
int dy[] = {1, 0, 0, -1};
bool valid(int x, int y) { return x >= 0 && y >= 0 && x < n && y < m; }
void dfs(int x, int y, int p1, int p2) {
  if (!valid(x, y) || visited[x][y]) return;
  visited[x][y] = 1;
  for (int k = 0; k < 4; k++) {
    int toX = x + dx[k];
    int toY = y + dy[k];
    if (arr[toX][toY] == arr[x][y]) {
      if (visited[toX][toY] && toX != p1 && toY != p2) found = true;
      dfs(toX, toY, x, y);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!visited[i][j]) {
        icount = 0;
        a = i, b = j;
        now = arr[i][j];
        dfs(i, j, -1, -1);
      }
    }
  }
  if (found)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
