#include <bits/stdc++.h>
using namespace std;
int64_t n, m, l = 0;
string s1[59];
bool v[55][55];
void fun(int i, int j, int x, int y) {
  v[i][j] = true;
  if (l == 1) return;
  if (i < n - 1 && s1[i + 1][j] == s1[i][j]) {
    if (v[i + 1][j] == false)
      fun(i + 1, j, i, j);
    else if (i + 1 != x || j != y) {
      l = 1;
      return;
    }
  }
  if (i > 0 && s1[i - 1][j] == s1[i][j]) {
    if (v[i - 1][j] == false)
      fun(i - 1, j, i, j);
    else if (i - 1 != x || j != y) {
      l = 1;
      return;
    }
  }
  if (j > 0 && s1[i][j - 1] == s1[i][j]) {
    if (v[i][j - 1] == false)
      fun(i, j - 1, i, j);
    else if (i != x || j - 1 != y) {
      l = 1;
    }
  }
  if (j < m - 1 && s1[i][j + 1] == s1[i][j]) {
    if (v[i][j + 1] == false)
      fun(i, j + 1, i, j);
    else if (i != x || j + 1 != y) {
      l = 1;
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s1[i];
  memset(v, false, sizeof(v));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (v[i][j] == false) fun(i, j, i, j);
      if (l == 1) break;
    }
    if (l == 1) break;
  }
  if (l == 1)
    cout << "Yes";
  else
    cout << "No";
}
