#include <bits/stdc++.h>
using namespace std;
vector<char> a[51];
int vis[51][51];
char z;
bool f = false;
int n, m;
bool valid(int x, int y, int dx, int dy) {
  if (x == dx && y == dy) return false;
  if (x < 0 || y < 0 || x >= n || y >= m) return false;
  if (a[x][y] != z) return false;
  return true;
}
void dfs(int x, int y, int dx, int dy) {
  if (vis[x][y] == 1) {
    f = true;
    vis[x][y] = 2;
    return;
  }
  if (vis[x][y] == 2) return;
  vis[x][y] = 1;
  if (valid(x + 1, y, dx, dy)) dfs(x + 1, y, x, y);
  if (valid(x, y + 1, dx, dy)) dfs(x, y + 1, x, y);
  if (valid(x - 1, y, dx, dy)) dfs(x - 1, y, x, y);
  if (valid(x, y - 1, dx, dy)) dfs(x, y - 1, x, y);
  vis[x][y] = 2;
}
int main() {
  memset(vis, 0, sizeof(vis));
  char x;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> x;
      a[i].push_back(x);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      z = a[i][j];
      dfs(i, j, i, j);
      memset(vis, 0, sizeof(vis));
      if (f) break;
    }
  }
  if (f)
    cout << "Yes";
  else
    cout << "No";
}
