#include <bits/stdc++.h>
using namespace std;
int n, m, dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
vector<string> v;
bool ch[26], flag = 0, vis[55][55];
void dfs(char cur, int cx, int cy, int px, int py) {
  if (vis[cy][cx] || flag || v[cy][cx] != cur) return;
  vis[cy][cx] = 1;
  for (int i = 0; i < 4; i++) {
    if (cy + dy[i] >= 0 && cx + dx[i] >= 0 && cy + dy[i] < n &&
        cx + dx[i] < m && (cy + dy[i] != py || cx + dx[i] != px)) {
      if (vis[cy + dy[i]][cx + dx[i]] && v[cy + dy[i]][cx + dx[i]] == cur) {
        flag = 1;
        return;
      } else if (v[cy + dy[i]][cx + dx[i]] != cur)
        vis[cy + dy[i]][cx + dx[i]] = 1;
      else
        dfs(cur, cx + dx[i], cy + dy[i], cx, cy);
    }
  }
}
int main() {
  memset(vis, 0, sizeof(vis));
  cin >> n >> m;
  v.resize(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) ch[v[i][j] - 65] = 1;
  }
  int ref = 0, l, r;
  char c;
  while (ref < 26 && !flag) {
    if ((ch[ref])) {
      c = (char)(ref + 65);
      l = 0;
      r = 0;
      while (l < m && !flag) {
        r = 0;
        while (r < n && !flag) {
          dfs(c, l, r, -1, -1);
          r++;
        }
        l++;
      }
    }
    ref++;
    memset(vis, 0, sizeof(vis));
  }
  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
