#include <bits/stdc++.h>
using namespace std;
char base[60][60];
int used[60][60];
int flag;
void dfs(int i, int j, int d) {
  if (flag) return;
  if (base[i + 1][j] == base[i][j] && d != 3) {
    if (used[i + 1][j] == 1) flag = 1;
    used[i + 1][j] = 1;
    dfs(i + 1, j, 1);
  }
  if (base[i][j + 1] == base[i][j] && d != 4) {
    if (used[i][j + 1] == 1) flag = 1;
    used[i][j + 1] = 1;
    dfs(i, j + 1, 2);
  }
  if (base[i - 1][j] == base[i][j] && d != 1) {
    if (used[i - 1][j] == 1) flag = 1;
    used[i - 1][j] = 1;
    dfs(i - 1, j, 3);
  }
  if (base[i][j - 1] == base[i][j] && d != 2) {
    if (used[i][j - 1] == 1) flag = 1;
    used[i][j - 1] = 1;
    dfs(i, j - 1, 4);
  }
}
int main() {
  int n, m, i, j;
  cin >> n >> m;
  memset(base, 120, sizeof(base));
  memset(used, 0, sizeof(used));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> base[i][j];
  flag = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (used[i][j] != 1) {
        used[i][j] = 1;
        dfs(i, j, 1);
      }
    }
  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
