#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0), eps = 1e-9;
char gc() {
  char c;
  while ((c = getchar()) <= ' ' && c != -1)
    ;
  return c;
}
int gs(char* s) {
  if (!fgets(s, 999999, stdin)) return -1;
  int l = strlen(s);
  while (l && (s[l - 1]) <= ' ') s[--l] = 0;
  return l;
}
string s[1010];
int sm[1010][1010], a[1010][1010];
bool query(int a1, int b1, int a2, int b2) {
  if (a2 < a1) swap(a1, a2);
  if (b2 < b1) swap(b1, b2);
  return sm[a2 + 1][b2 + 1] - sm[a1][b2 + 1] - sm[a2 + 1][b1] + sm[a1][b1] ==
         (a2 - a1 + 1) * (b2 - b1 + 1);
}
int co[256];
int mx[4] = {-1, 0, 1, 0};
int my[4] = {0, 1, 0, -1};
int main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  co['N'] = 0;
  co['E'] = 1;
  co['S'] = 2;
  co['W'] = 3;
  int n, m;
  cin >> n >> m;
  for (int i = 0, _i = (n); i < _i; i++) {
    cin >> s[i];
  }
  for (int i = 0, _i = (n); i < _i; i++) {
    for (int j = 0, _j = (m); j < _j; j++) {
      if (s[i][j] != '#')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  for (int i = 0, _i = (n); i < _i; i++) {
    for (int j = 0, _j = (m); j < _j; j++) {
      sm[i + 1][j + 1] = sm[i][j + 1] + sm[i + 1][j] - sm[i][j] + a[i][j];
    }
  }
  vector<pair<int, int> > mv;
  int k;
  cin >> k;
  for (int i = 0, _i = (k); i < _i; i++) {
    char s;
    int t;
    cin >> s >> t;
    mv.push_back(pair<int, int>(co[s], t));
  }
  vector<int> v;
  for (int i = 0, _i = (n); i < _i; i++) {
    for (int j = 0, _j = (m); j < _j; j++) {
      if (s[i][j] >= 'A' && s[i][j] <= 'Z') {
        int ci = i;
        int cj = j;
        bool f = true;
        for (int a = 0, _a = (k); a < _a; a++) {
          int ni = ci + mx[mv[a].first] * mv[a].second;
          int nj = cj + my[mv[a].first] * mv[a].second;
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) {
            f = false;
            break;
          }
          if (!query(ci, cj, ni, nj)) {
            f = false;
            break;
          }
          ci = ni;
          cj = nj;
        }
        if (f) {
          v.push_back(s[i][j]);
        }
      }
    }
  }
  if (((int)(v).size()) == 0) {
    cout << "no solution" << '\n';
  }
  sort((v).begin(), (v).end());
  for (__typeof((v).begin()) i = (v).begin(), _i = (v).end(); i != _i; i++) {
    cout << char(*i);
  }
}
