func_code_string: #include <bits/stdc++.h>   using namespace std;   const int mod = 1e9 + 7;   const int INF = 1e9;   int n, m;   char mt[1505][1505];   const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};   bool flag = false;   pair<int, int> vis[1505][1505];   void dfs(int x, int y) {     int ax = (x % n + n) % n, ay = (y % m + m) % m;     if (mt[ax][ay] ==  # ) return;     if (vis[ax][ay] != make_pair(INF, INF) && vis[ax][ay] != make_pair(x, y)) {       flag = true;       return;     }     if (vis[ax][ay] != make_pair(INF, INF)) return;     vis[ax][ay] = make_pair(x, y);     for (int i = 0; i < 4; i++) dfs(x + dx[i], y + dy[i]);   }   int main() {     ios_base::sync_with_stdio(false);     cin >> n >> m;     int sx, sy;     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++) vis[i][j] = make_pair(INF, INF);     for (int i = 0; i < n; i++) {       cin >> mt[i];       for (int j = 0; j < m; j++)         if (mt[i][j] ==  S ) sx = i, sy = j;     }     dfs(sx, sy), cout << (flag == true ?  Yes  :  No );     return 0;   }   