#include <bits/stdc++.h>
using namespace std;
int conv(char c) {
  if (c == 'W') return (0);
  if (c == 'N') return (1);
  if (c == 'E') return (2);
  return (3);
}
int dy[] = {0, -1, 0, 1};
int dx[] = {-1, 0, 1, 0};
int main() {
  int w, h;
  static char mp[1024][1024];
  static int lim[4][1024][1024];
  static int dir[100000], len[100000];
  vector<pair<char, pair<int, int> > > pt;
  scanf("%d %d", &h, &w);
  for (int i = 0; i < h; i++) {
    scanf("%s", mp[i]);
    for (int j = 0; j < w; j++) {
      if ('A' <= mp[i][j] && mp[i][j] <= 'Z') {
        pt.push_back(pair<char, pair<int, int> >(mp[i][j], make_pair(i, j)));
      }
    }
  }
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      lim[0][i][j] = (j == 0 ? (mp[i][j] == '#' ? -1 : 0)
                             : (mp[i][j] == '#' ? -1 : lim[0][i][j - 1] + 1));
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++)
      lim[1][i][j] = (i == 0 ? (mp[i][j] == '#' ? -1 : 0)
                             : (mp[i][j] == '#' ? -1 : lim[1][i - 1][j] + 1));
  for (int i = h - 1; i >= 0; i--)
    for (int j = w - 1; j >= 0; j--)
      lim[2][i][j] =
          (j == w - 1 ? (mp[i][j] == '#' ? -1 : 0)
                      : (mp[i][j] == '#' ? -1 : lim[2][i][j + 1] + 1));
  for (int i = h - 1; i >= 0; i--)
    for (int j = w - 1; j >= 0; j--)
      lim[3][i][j] =
          (i == h - 1 ? (mp[i][j] == '#' ? -1 : 0)
                      : (mp[i][j] == '#' ? -1 : lim[3][i + 1][j] + 1));
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; i++) {
    char d[2];
    scanf("%s %d", d, len + i);
    dir[i] = conv(d[0]);
  }
  vector<char> ans;
  for (int i = 0; i < pt.size(); i++) {
    int ty = pt[i].second.first, tx = pt[i].second.second;
    bool ok = true;
    for (int j = 0; j < q; j++) {
      if (lim[dir[j]][ty][tx] >= len[j]) {
        ty += dy[dir[j]] * len[j];
        tx += dx[dir[j]] * len[j];
      } else {
        ok = false;
        break;
      }
    }
    if (ok) ans.push_back(pt[i].first);
  }
  sort(ans.begin(), ans.end());
  if (!ans.size()) return (!printf("no solution\n"));
  for (int i = 0; i < ans.size(); i++) {
    printf("%c", ans[i]);
  }
  printf("\n");
  return (0);
}
