#include <bits/stdc++.h>   using namespace std;   int n, m;   char grid[55][55];   char vis[55][55];   int di[] = {0, 1, -1, 0};   int dj[] = {1, 0, 0, -1};   bool dfs(int pi, int pj, char c, int li = -1, int lj = -1) {     if (vis[pi][pj]) return true;     vis[pi][pj] = true;     for (int d = 0; d < 4; d++) {       int ni = pi + di[d];       int nj = pj + dj[d];       if (ni == li && nj == lj) continue;       if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;       if (grid[ni][nj] != c) continue;       if (dfs(ni, nj, c, pi, pj)) return true;     }     return false;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) {       cin >> grid[i];     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < m; j++) {         if (vis[i][j] == false) {           if (dfs(i, j, grid[i][j])) {             cout <<  Yes  << endl;             return 0;           }         }       }     }     cout <<  No  << endl;     return 0;   }   