#include <bits/stdc++.h>
using namespace std;
const int Maxn = 50 + 10;
string a[Maxn];
int tt, m, n;
vector<pair<int, int> > nei[Maxn * Maxn];
pair<int, int> par[Maxn][Maxn];
bool bl, mark[Maxn][Maxn];
void input() {
  cin >> m >> n;
  for (int i = 0; i < m; i++) cin >> a[i];
}
void found(int i, int j) {
  int t = i * n + j;
  if (i > 0 && a[i - 1][j] == a[i][j]) {
    pair<int, int> z = make_pair(i - 1, j);
    nei[t].push_back(z);
  }
  if (i < m - 1 && a[i + 1][j] == a[i][j]) {
    pair<int, int> z = make_pair(i + 1, j);
    nei[t].push_back(z);
  }
  if (j > 0 && a[i][j - 1] == a[i][j]) {
    pair<int, int> z = make_pair(i, j - 1);
    nei[t].push_back(z);
  }
  if (j < n - 1 && a[i][j + 1] == a[i][j]) {
    pair<int, int> z = make_pair(i, j + 1);
    nei[t].push_back(z);
  }
  return;
}
void hamsaye() {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++) found(i, j);
}
void dfs(int v, int w) {
  int t = v * n + w;
  mark[v][w] = true;
  for (int i = 0; i < nei[t].size(); i++) {
    pair<int, int> u = nei[t][i];
    if (mark[u.first][u.second])
      if (par[v][w] != make_pair(u.first, u.second)) bl = true;
    if (!mark[u.first][u.second]) {
      par[u.first][u.second] = make_pair(v, w);
      dfs(u.first, u.second);
    }
  }
  return;
}
void dfs_all() {
  for (int i = 0; i < m; i++)
    for (int j = 0; j < n; j++)
      if (!mark[i][j]) dfs(i, j);
}
int main() {
  input();
  hamsaye();
  dfs_all();
  if (bl)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
