#include <bits/stdc++.h>
using namespace std;
char a[52][52];
bool br = 0;
int n, m;
bool mas[52][52];
int z1[4] = {0, 0, -1, 1};
int z2[4] = {-1, 1, 0, 0};
void fun(int x, int y, int ax, int ay, char ch) {
  if (x >= n || y >= m || x < 0 || y < 0) return;
  if (a[x][y] != ch) return;
  if (mas[x][y]) {
    br = 1;
    return;
  }
  mas[x][y] = 1;
  for (int i = 0; i < 4; i++) {
    int aax = x + z1[i];
    int aay = y + z2[i];
    if (aax == ax && aay == ay) continue;
    fun(aax, aay, x, y, ch);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  char z;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (!mas[i][j]) {
        fun(i, j, -1, -1, a[i][j]);
        if (br) {
          cout << "Yes";
          return 0;
        }
      }
    }
  cout << "No";
}
