func_code_string: #include <bits/stdc++.h>   using namespace std;   int dx[] = {1, 0, -1, 0, -1, 1, -1, 1};   int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};   const double eps = 1e-6;   const int N = 1e9;   void moha() {}   bool vis[1505][1505];   int comp[1505][1505][2];   char x[1505][1505];   int n, m;   int row(int x) { return (x + n * 1500) % n; }   int col(int y) { return (y + m * 1500) % m; }   int main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout.tie(0);     cin >> n >> m;     int a, b;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) {         cin >> x[i][j];         if (x[i][j] ==  S ) {           a = i;           b = j;         }       }     queue<pair<int, int> > q;     q.push({a, b});     vis[a][b] = 1;     comp[row(a)][col(b)][0] = a;     comp[row(a)][col(b)][1] = b;     while (!q.empty()) {       pair<int, int> p = q.front();       q.pop();       for (int i = 0; i < 4; i++) {         int xx = p.first + dx[i];         int yy = p.second + dy[i];         if (x[row(xx)][col(yy)] ==  # ) continue;         if (vis[row(xx)][col(yy)]) {           if (comp[row(xx)][col(yy)][0] != xx ||               comp[row(xx)][col(yy)][1] != yy) {             cout <<  Yes  << endl;             return 0;           }           continue;         }         q.push({xx, yy});         vis[row(xx)][col(yy)] = 1;         comp[row(xx)][col(yy)][0] = xx;         comp[row(xx)][col(yy)][1] = yy;       }     }     cout <<  No  << endl;     return 0;   }   