func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   vector<pair<int, int>> g[51][51];   int ch[51][51], vis[51][51], cnt;   pair<int, int> par[51][51];   bool isValid(int x, int y) {     if (x < 0 || y < 0 || x > n - 1 || y > m - 1) return false;     return true;   }   int dx[] = {-1, 0, 0, 1};   int dy[] = {0, 1, -1, 0};   void dfs(int x, int y, int px, int py) {     vis[x][y] = 1;     par[x][y] = {px, py};     for (auto i = 0; i < 4; i++) {       int curX = x + dx[i], curY = y + dy[i];       if (isValid(curX, curY) && ch[curX][curY] == ch[x][y]) {         if (vis[curX][curY] == 0)           dfs(curX, curY, x, y);         else if (par[x][y].first != curX || par[x][y].second != curY)           cnt++;       }     }   }   void Solve() {     cin >> n >> m;     for (auto i = 0; i < n; i++) {       for (auto j = 0; j < m; j++) {         char c;         cin >> c;         ch[i][j] = c -  A  + 1;       }     }     for (auto i = 0; i < n - 1; i++) {       for (auto j = 0; j < m - 1; j++) {         if (ch[i + 1][j] == ch[i][j])           g[i][j].push_back({i + 1, j}), g[i + 1][j].push_back({i, j});         if (ch[i][j + 1] == ch[i][j + 1])           g[i][j].push_back({i, j + 1}), g[i][j + 1].push_back({i, j});       }     }     for (auto i = 0; i < n; i++) {       for (auto j = 0; j < m; j++) {         if (vis[i][j] == 0) {           cnt = 0;           dfs(i, j, -1, -1);           if (cnt > 0) {             cout <<  Yes ;             return;           }         }       }     }     cout <<  No ;   }   int main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long int T = 1;     while (T--) Solve();     return 0;   }   