func_code_string: #include <bits/stdc++.h>   using namespace std;   char field[1000][1000];   int deltas[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};   int n, m;   int si, sj, ti, tj;   bool possible;   void go(int i, int j, char num) {     for (auto d : deltas) {       int ii = i;       int jj = j;       while (true) {         ii += d[0];         jj += d[1];         if (ii < 0 || jj < 0 || ii >= n || jj >= m) break;         if (field[ii][jj] ==  T ) possible = true;         if (field[ii][jj] !=  . ) break;         field[ii][jj] = num;       }     }   }   int main() {     ios::sync_with_stdio(false);     cin >> n >> m;     for (int i = 0; i < n; i++) {       string line;       cin >> line;       for (int j = 0; j < m; j++) {         field[i][j] = line[j];         if (line[j] ==  T ) {           ti = i;           tj = j;         }         if (line[j] ==  S ) {           si = i;           sj = j;         }       }     }     go(si, sj,  0 );     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (field[i][j] ==  0 ) {           go(i, j,  1 );         }       }     }     for (int i = 0; i < n; i++) {       for (int j = 0; j < n; j++) {         if (field[i][j] ==  1 ) {           go(i, j,  2 );         }       }     }     if (possible)       cout <<  YES  << endl;     else       cout <<  NO  << endl;     return 0;   }   