#include <bits/stdc++.h>
using namespace std;
char mp[1200][1200];
int d[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}};
int sum1[1100][1100];
int sum2[1100][1100];
struct Q {
  int dir;
  int len;
} node[110000];
struct RE {
  char c;
  bool operator<(const RE &ret) const { return c < ret.c; }
} re[1100];
int Dep;
int n, m;
bool check(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < m && mp[x][y] != '#') return true;
  return false;
}
bool dfs(int x, int y, int depth) {
  if (depth == Dep) {
    return true;
  }
  int dir = node[depth].dir;
  int len = node[depth].len;
  int nx = x + d[0][dir] * len;
  int ny = y + d[1][dir] * len;
  bool flag = true;
  if (!check(nx, ny)) {
    flag = false;
  } else {
    int tmp;
    if (dir == 0) {
      tmp;
      if (nx == 0)
        tmp = sum2[y][x];
      else
        tmp = sum2[y][x] - sum2[y][nx - 1];
    } else if (dir == 2) {
      tmp;
      if (x == 0)
        tmp = sum2[y][nx];
      else
        tmp = sum2[y][nx] - sum2[y][x - 1];
    } else if (dir == 1) {
      tmp;
      if (y == 0)
        tmp = sum1[x][ny];
      else
        tmp = sum1[x][ny] - sum1[x][y - 1];
    } else {
      tmp;
      if (ny == 0)
        tmp = sum1[x][y];
      else
        tmp = sum1[x][y] - sum1[x][ny - 1];
    }
    if (tmp < 0) flag = false;
  }
  if (flag) {
    return dfs(nx, ny, depth + 1);
  } else
    return false;
}
char s[100];
int main() {
  int k;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) scanf("%s", mp[i]);
    memset(sum1, 0, sizeof(sum1));
    memset(sum2, 0, sizeof(sum2));
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        int w;
        if (mp[i][j] == '#')
          w = -1;
        else
          w = 0;
        if (j == 0)
          sum1[i][j] = w;
        else
          sum1[i][j] = sum1[i][j - 1] + w;
      }
    for (int j = 0; j < m; j++)
      for (int i = 0; i < n; i++) {
        int w;
        if (mp[i][j] == '#')
          w = -1;
        else
          w = 0;
        if (i == 0)
          sum2[j][i] = w;
        else
          sum2[j][i] = sum2[j][i - 1] + w;
      }
    scanf("%d", &k);
    Dep = k;
    for (int i = 0; i <= k - 1; i++) {
      scanf("%s%d", s, &node[i].len);
      if (s[0] == 'N')
        node[i].dir = 0;
      else if (s[0] == 'E')
        node[i].dir = 1;
      else if (s[0] == 'S')
        node[i].dir = 2;
      else
        node[i].dir = 3;
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (mp[i][j] >= 'A' && mp[i][j] <= 'Z') {
          if (dfs(i, j, 0)) {
            re[cnt++].c = mp[i][j];
          }
        }
      }
    if (cnt > 0) {
      sort(re, re + cnt);
      for (int i = 0; i < cnt; i++) printf("%c", re[i].c);
      printf("\n");
    } else {
      printf("no solution\n");
    }
  }
  return 0;
}
