func_code_string: #include <bits/stdc++.h>   using namespace std;   const int cap = 1e3;   int n, m;   char grid[cap][cap];   int vis[4][cap][cap] = {};   vector<pair<int, int>> dirs = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};   bool dfs(int i, int j, int d, int t) {     if (i < 0 || i == n || j < 0 || j == m || grid[i][j] ==  *  ||         (vis[d][i][j] != -1 && t >= vis[d][i][j]))       return false;     if (grid[i][j] ==  T ) return true;     vis[d][i][j] = t;     int x, y;     x = i + dirs[d].first;     y = j + dirs[d].second;     if (dfs(x, y, d, t)) return true;     if (t < 2)       for (int k = 0; k < 4; ++k)         if (k != d) {           x = i + dirs[k].first;           y = j + dirs[k].second;           if (dfs(x, y, k, t + 1)) return true;         }     return false;   }   int main() {     memset(vis, -1, sizeof vis);     scanf( %d %d , &n, &m);     int i_s = -1, j_s = -1;     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) {         scanf(  %c , &grid[i][j]);         if (grid[i][j] ==  S ) {           i_s = i;           j_s = j;         }       }     for (int d = 0; d < 4; ++d)       if (dfs(i_s, j_s, d, 0)) {         printf( YES );         return 0;       }     printf( NO );     return 0;   }   