#include <bits/stdc++.h>
using namespace std;
const int maxn = 1030;
struct tt {
  int x, y;
  char c;
};
struct oo {
  int no;
  int num;
} o[100100];
int n, m, k;
char mm[maxn][maxn];
int xx[4] = {-1, 0, 1, 0};
int yy[4] = {0, 1, 0, -1};
vector<tt> sight;
int cmp(tt aa, tt bb) { return aa.c < bb.c; }
int go[maxn][maxn][4];
bool check(int h) {
  int i, j;
  int x, y;
  x = sight[h].x;
  y = sight[h].y;
  for (i = 0; i < k; ++i) {
    if (go[x][y][o[i].no] < o[i].num) return 0;
    x += xx[o[i].no] * o[i].num;
    y += yy[o[i].no] * o[i].num;
  }
  return 1;
}
void init() {
  int i, j, t = 0, k;
  for (i = 1; i <= m; ++i) {
    for (j = 1; j <= n; ++j) {
      if (mm[j][i] == '#') {
        for (k = 0; k < t; ++k) go[j - k - 1][i][2] = k;
        t = 0;
      } else {
        t++;
        go[j][i][0] = t - 1;
      }
    }
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (mm[i][j] == '#') {
        for (k = 0; k < t; ++k) go[i][j - k - 1][1] = k;
        t = 0;
      } else {
        t++;
        go[i][j][3] = t - 1;
      }
    }
  }
}
int main() {
  int i, j;
  char s[10];
  tt temp;
  bool ok;
  while (scanf("%d %d", &n, &m) != EOF) {
    sight.clear();
    for (i = 1; i <= n; ++i) scanf("%s", mm[i] + 1);
    for (i = 0; i <= n + 1; ++i) mm[i][0] = mm[i][m + 1] = '#';
    for (i = 0; i <= m + 1; ++i) mm[0][i] = mm[n + 1][i] = '#';
    init();
    for (i = 0; i <= n + 1; ++i)
      for (j = 0; j <= m + 1; ++j)
        if (mm[i][j] - '.' && mm[i][j] - '#') {
          temp.c = mm[i][j];
          temp.x = i;
          temp.y = j;
          sight.push_back(temp);
        }
    scanf("%d", &k);
    for (i = 0; i < k; ++i) {
      scanf("%s %d", s, &j);
      if (s[0] == 'N')
        o[i].no = 0;
      else if (s[0] == 'S')
        o[i].no = 2;
      else if (s[0] == 'E')
        o[i].no = 1;
      else
        o[i].no = 3;
      o[i].num = j;
    }
    ok = 0;
    sort(sight.begin(), sight.end(), cmp);
    for (i = 0; i < sight.size(); ++i) {
      if (check(i)) {
        printf("%c", sight[i].c);
        ok = 1;
      }
    }
    if (!ok) printf("no solution");
    printf("\n");
  }
  return 0;
}
