#include <bits/stdc++.h>
using namespace std;
int n, m;
char r[52][52];
bool vis[52][52], ans = false;
bool valid(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m) return false;
  return true;
}
void dfs(int i, int j, int ld) {
  if (ld != 3 && r[i][j + 1] == r[i][j] && valid(i, j + 1)) {
    if (vis[i][j + 1]) {
      ans = true;
      return;
    } else
      vis[i][j + 1] = 1;
    dfs(i, j + 1, 1);
  }
  if (ld != 4 && r[i - 1][j] == r[i][j] && valid(i - 1, j)) {
    if (vis[i - 1][j]) {
      ans = true;
      return;
    } else
      vis[i - 1][j] = 1;
    dfs(i - 1, j, 2);
  }
  if (ld != 1 && r[i][j - 1] == r[i][j] && valid(i, j - 1)) {
    if (vis[i][j - 1]) {
      ans = true;
      return;
    } else
      vis[i][j - 1] = 1;
    dfs(i, j - 1, 3);
  }
  if (ld != 2 && r[i + 1][j] == r[i][j] && valid(i + 1, j)) {
    if (vis[i + 1][j]) {
      ans = true;
      return;
    } else
      vis[i + 1][j] = 1;
    dfs(i + 1, j, 4);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> r[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (!vis[i][j]) dfs(i, j, 0);
  ans ? cout << "Yes" : cout << "No";
}
