#include <bits/stdc++.h>
using namespace std;
char M[1000][1001], dir[100000];
int S[4][1000][1000], len[100000], attx[26], atty[26], atcnt;
int d[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
bool valid[26];
int num(char c) {
  switch (c) {
    case 'N':
      return 0;
      break;
    case 'E':
      return 1;
      break;
    case 'S':
      return 2;
      break;
    default:
      return 3;
      break;
  }
}
int main() {
  int n, m, i, j, k, l, p, q, id;
  bool pos;
  char ans[27];
  scanf("%d%d", &n, &m);
  atcnt = 0;
  for (i = 0; i < n; i++) {
    scanf("%s", M[i]);
    for (pos = j = 0; j < m; j++)
      if (M[i][j] == '#') {
        if (pos)
          for (p = 1, q = j - l - 1; l + p < j; p++, q--) {
            S[3][i][l + p] = p;
            S[1][i][l + p] = q;
          }
        pos = false;
        l = j;
      } else {
        if (M[i][j] != '.') {
          attx[atcnt] = j;
          atty[atcnt] = i;
          atcnt++;
        }
        pos = true;
      }
  }
  for (j = 0; j < m; j++)
    for (pos = i = 0; i < n; i++)
      if (M[i][j] == '#') {
        if (pos)
          for (p = 1, q = i - l - 1; l + p < i; p++, q--) {
            S[0][l + p][j] = p;
            S[2][l + p][j] = q;
          }
        pos = false;
        l = i;
      } else
        pos = true;
  scanf("%d", &k);
  getchar();
  for (i = 0; i < k; i++) {
    scanf("%c%d", dir + i, len + i);
    getchar();
  }
  memset(valid, 1, sizeof(valid));
  for (p = 0; p < atcnt; p++) {
    i = atty[p];
    j = attx[p];
    for (l = 0; l < k; l++) {
      id = num(dir[l]);
      if (S[id][i][j] <= len[l]) {
        valid[p] = false;
        break;
      }
      i += d[id][0] * len[l];
      j += d[id][1] * len[l];
      if (i < 0 || n < i || j < 0 || m < j) {
        valid[p] = false;
        break;
      }
    }
  }
  for (p = k = 0; p < atcnt; p++)
    if (valid[p]) ans[k++] = M[atty[p]][attx[p]];
  ans[k] = '\0';
  sort(ans, ans + k);
  if (k)
    puts(ans);
  else
    puts("no solution");
  return 0;
}
