#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
const int mod = 1e9 + 7;
string str[51];
int vis[51][51];
int n, m;
int nodes = 0;
int edges;
void dfs(int x, int y, char ch) {
  if (x == -1 || y == -1 || x == n || y == m) return;
  if (str[x][y] != ch || vis[x][y] == 1) return;
  vis[x][y] = 1;
  if (x + 1 < n && str[x + 1][y] == str[x][y]) edges++;
  if (y + 1 < m && str[x][y + 1] == str[x][y]) edges++;
  nodes++;
  dfs(x + 1, y, ch);
  dfs(x - 1, y, ch);
  dfs(x, y + 1, ch);
  dfs(x, y - 1, ch);
}
signed main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j]) {
        nodes = 0;
        edges = 0;
        dfs(i, j, str[i][j]);
        if (nodes <= edges) {
          cout << "Yes\n";
          return 0;
        }
      }
    }
  }
  cout << "No\n";
}
