func_code_string: #include <bits/stdc++.h>   #pragma comment(linker,  /stack:200000000 )   #pragma GCC optimize( Ofast,no-stack-protector )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native )   #pragma GCC optimize( unroll-loops )   const int MAX = 2e3 + 10;   const int MOD = 1e9 + 7;   using namespace std;   int n, m;   char s[MAX][MAX];   int vis[30], x[30], y[30];   int sum1[MAX][MAX], sum2[MAX][MAX];   bool f(int a, int b) {     if (a < 1 || b < 1 || a > n || b > m) return false;     return true;   }   int main() {     ios::sync_with_stdio(false), cout.tie(NULL);     cin >> n >> m;     for (int i = 1; i <= n; i++) cin >> (s[i] + 1);     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         sum1[i][j] = sum1[i - 1][j];         sum2[i][j] = sum2[i][j - 1];         if (s[i][j] ==  # ) {           sum1[i][j]++;           sum2[i][j]++;         } else if (s[i][j] !=  . ) {           vis[s[i][j] -  A ] = 1;           x[s[i][j] -  A ] = i;           y[s[i][j] -  A ] = j;         }       }     }     int k;     cin >> k;     while (k--) {       char dir[2];       int len;       cin >> dir >> len;       if (dir[0] ==  N ) {         for (int i = 0; i < 27; i++) {           if (vis[i]) {             int xx = x[i] - len;             if (!f(xx, y[i]) || sum1[x[i]][y[i]] != sum1[xx - 1][y[i]])               vis[i] = 0;             x[i] = xx;           }         }       } else if (dir[0] ==  S ) {         for (int i = 0; i < 27; i++) {           if (vis[i]) {             int xx = x[i] + len;             if (!f(xx, y[i]) || sum1[x[i]][y[i]] != sum1[xx][y[i]]) vis[i] = 0;             x[i] = xx;           }         }       } else if (dir[0] ==  W ) {         for (int i = 0; i < 27; i++) {           if (vis[i]) {             int yy = y[i] - len;             if (!f(x[i], yy) || sum2[x[i]][y[i]] != sum2[x[i]][yy - 1])               vis[i] = 0;             y[i] = yy;           }         }       } else {         for (int i = 0; i < 27; i++) {           if (vis[i]) {             int yy = y[i] + len;             if (!f(x[i], yy) || sum2[x[i]][y[i]] != sum2[x[i]][yy]) {               vis[i] = 0;             }             y[i] = yy;           }         }       }     }     int fg = 0;     for (int i = 0; i < 27; i++) {       if (vis[i]) {         fg = 1;         cout << char(i +  A );       }     }     if (!fg) cout <<  no solution ;     cout << endl;   }   