func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m, top, len[100005], F1[1005][1005], F2[1005][1005];   pair<int, int> F[30];   char ans[30], dir[100005], a[1005][1005];   bool outside(int first, int second) {     return (first < 1 || first > n || second < 1 || second > m);   }   int tinh1(int first, int y1, int y2) {     if (y1 > y2) swap(y1, y2);     return F1[first][y2] - F1[first][y1 - 1];   }   int tinh2(int second, int x1, int x2) {     if (x1 > x2) swap(x1, x2);     return F2[x2][second] - F2[x1 - 1][second];   }   void tinh(int first, int second, int i, int& x2, int& y2) {     int dx = 0, dy = 0;     if (dir[i] ==  N )       dx = -1;     else if (dir[i] ==  S )       dx = 1;     else if (dir[i] ==  W )       dy = -1;     else if (dir[i] ==  E )       dy = 1;     x2 = first + dx * len[i], y2 = second + dy * len[i];   }   int main() {     scanf( %d%d n , &n, &m);     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         scanf( %c , &a[i][j]);         if (a[i][j] >=  A  && a[i][j] <=  Z ) {           F[a[i][j]] = pair<int, int>(i, j);           a[i][j] =  . ;         }       }       scanf(  n );     }     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= m; ++j) {         F1[i][j] = F1[i][j - 1] + (a[i][j] ==  # );         F2[i][j] = F2[i - 1][j] + (a[i][j] ==  # );       }     int k;     scanf( %d n , &k);     for (int i = 1; i <= k; ++i) scanf( %c %d n , &dir[i], &len[i]);     for (char t =  A ; t <=  Z ; ++t)       if (F[t].first != 0) {         int first = F[t].first, second = F[t].second;         bool b = true;         for (int i = 1; i <= k; ++i) {           int x2, y2;           tinh(first, second, i, x2, y2);           if (outside(x2, y2) || (x2 == first && tinh1(first, second, y2) != 0) ||               (y2 == second && tinh2(second, first, x2) != 0)) {             b = false;             break;           }           first = x2, second = y2;         }         if (b) ans[++top] = t;       }     if (!top)       cout <<  no solution  << endl;     else {       for (int i = 1; i <= top; ++i) printf( %c , ans[i]);     }     return 0;   }   