func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[1500][1500];   int visited[1500][1500];   int n, m;   struct node {     int x, y;   };   node vis[1500][1500];   int main() {     int sx, sy;     char x;     scanf( %d%d , &n, &m);     for (int i = 0; i < n; i++) {       scanf(  n );       for (int j = 0; j < m; j++) {         scanf( %c , &x);         if (x ==  # )           a[i][j] = 0;         else if (x ==  . )           a[i][j] = 1;         else {           a[i][j] = 1;           sx = i;           sy = j;         }       }     }     bool flag = false;     visited[sx][sy] = 1;     vis[sx][sy].x = sx;     vis[sx][sy].y = sy;     queue<node> q;     node tmp;     tmp.x = sx;     tmp.y = sy;     q.push(tmp);     while (!q.empty()) {       tmp = q.front();       q.pop();       node tmp1, tmp2;       tmp1.x = tmp.x;       tmp1.y = tmp.y - 1;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x;       tmp1.y = tmp.y + 1;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x - 1;       tmp1.y = tmp.y;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }       tmp1.x = tmp.x + 1;       tmp1.y = tmp.y;       tmp2 = tmp1;       tmp1.x = tmp1.x % n;       tmp1.y = tmp1.y % m;       if (tmp1.x < 0) tmp1.x += n;       if (tmp1.y < 0) tmp1.y += m;       if (visited[tmp1.x][tmp1.y] == 0 && a[tmp1.x][tmp1.y] == 1) {         visited[tmp1.x][tmp1.y] = 1;         vis[tmp1.x][tmp1.y] = tmp2;         q.push(tmp2);       } else if (visited[tmp1.x][tmp1.y] == 1 &&                  (vis[tmp1.x][tmp1.y].x != tmp2.x ||                   vis[tmp1.x][tmp1.y].y != tmp2.y)) {         flag = true;       }     }     if (flag)       printf( Yes n );     else       printf( No n );     return 0;   }   