#include <bits/stdc++.h>
struct node {
  int x, y;
  int dir, len;
} arr[1100 * 1100], st[1100];
int n, m, tot, vis[1100][1100], cnt;
int srow[1100][1100], scol[1100][1100];
int dir[4] = {1, -1, -1, 1};
char mmap[1100][1100];
void Initial() {
  int i, j, k;
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) srow[i][j] = srow[i][j - 1] + vis[i][j];
  for (j = 1; j <= m; ++j)
    for (i = 1; i <= n; ++i) scol[i][j] = scol[i - 1][j] + vis[i][j];
}
int GetDir(char c) {
  if (c == 'N') return 0;
  if (c == 'S') return 1;
  if (c == 'W') return 2;
  if (c == 'E') return 3;
}
int Isok(int in) {
  int i, j, k, x, y;
  x = st[in].x, y = st[in].y;
  for (i = 1; i <= tot; ++i) {
    int td = arr[i].dir, tl = arr[i].len;
    if (td == 0) {
      if (x - tl <= 0) return 0;
      if (scol[x][y] - scol[x - tl - 1][y] > 0) return 0;
      x -= tl;
    } else if (td == 1) {
      if (x + tl >= n + 1) return 0;
      if (scol[x + tl][y] - scol[x - 1][y] > 0) return 0;
      x += tl;
    } else if (td == 2) {
      if (y - tl <= 0) return 0;
      if (srow[x][y] - srow[x][y - tl - 1] > 0) return 0;
      y -= tl;
    } else {
      if (y + tl >= m + 1) return 0;
      if (srow[x][y + tl] - srow[x][y - 1] > 0) return 0;
      y += tl;
    }
  }
  cnt++;
  return 1;
}
int main() {
  int i, j, k;
  while (scanf("%d%d", &n, &m) != EOF) {
    for (i = 0; i < 26; ++i) st[i].x = -1;
    for (i = 1; i <= n; ++i) {
      scanf("%s", mmap[i] + 1);
      for (j = 1; j <= m; ++j) {
        if (mmap[i][j] >= 'A' && mmap[i][j] <= 'Z')
          st[mmap[i][j] - 'A'].x = i, st[mmap[i][j] - 'A'].y = j;
        vis[i][j] = mmap[i][j] == '#' ? 1 : 0;
      }
    }
    Initial();
    scanf("%d", &tot);
    for (i = 1; i <= tot; ++i) {
      char str[20];
      scanf("%s %d", str, &arr[i].len);
      arr[i].dir = GetDir(str[0]);
    }
    cnt = 0;
    for (i = 0; i < 26; ++i)
      if (st[i].x != -1 && Isok(i)) printf("%c", i + 'A');
    if (cnt == 0) printf("no solution\n");
    printf("\n");
  }
}
