#include <bits/stdc++.h>
using namespace std;
int const INF = (1 << 30);
int const MAXN = (int)2e3 + 100;
bool used[MAXN][MAXN];
bool use[MAXN / 2][MAXN / 2];
int n, m, k;
char a[MAXN / 2][MAXN / 2];
int const eps = (int)1e3 + 5;
vector<pair<pair<int, int>, char> > q;
vector<pair<int, int> > v;
bool check(int x, int y) { return (x < 1 || x > n || y < 1 || y > m); }
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] != '#' && a[i][j] != '.')
        q.push_back(make_pair(make_pair(i, j), a[i][j]));
      if (a[i][j] != '#') use[i][j] = true;
    }
  }
  scanf("%d", &k);
  int curx = eps;
  int cury = eps;
  for (int i = 1; i <= k; i++) {
    string tt;
    int len;
    cin >> tt;
    char t = tt[0];
    scanf("%d", &len);
    int curxx = 0;
    int curyy = 0;
    for (int j = 1; j <= len; j++) {
      if (t == 'N') {
        used[curx + j][cury] = true;
        curxx = curx + j;
        curyy = cury;
      } else if (t == 'S') {
        used[curx - j][cury] = true;
        curxx = curx - j;
        curyy = cury;
      } else if (t == 'E') {
        used[curx][cury - j] = true;
        curxx = curx;
        curyy = cury - j;
      } else {
        used[curx][cury + j] = true;
        curxx = curx;
        curyy = cury + j;
      }
      if (curxx > MAXN - 5 || curxx < 5 || curyy > MAXN - 5 || curyy < 5) {
        cout << "no solution" << endl;
        return 0;
      }
    }
    curx = curxx;
    cury = curyy;
  }
  for (int i = -n; i <= n; i++) {
    for (int j = -m; j <= m; j++) {
      if (used[i + eps][j + eps]) {
        v.push_back(make_pair(i, j));
      }
    }
  }
  vector<char> ans;
  for (int i = 0; i < q.size(); i++) {
    bool ok = false;
    for (int j = 0; j < v.size(); j++) {
      int x = v[j].first;
      int y = v[j].second;
      int xx = q[i].first.first - x;
      int yy = q[i].first.second - y;
      if (!use[xx][yy] || (check(xx, yy))) {
        ok = true;
        break;
      }
    }
    if (!ok) {
      ans.push_back(q[i].second);
    }
  }
  if (ans.size() == 0) {
    cout << "no solution" << endl;
    return 0;
  }
  sort(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) cout << ans[i];
  return 0;
}
