#include <bits/stdc++.h>
using namespace std;
char A[1010][1010];
vector<pair<int, int> > M;
vector<pair<int, int> > C;
int n, m, k;
int V[1010][1010];
int H[1010][1010];
bool Ax(int x, int y, int p, int q) {
  if (A[x][y] == '#' || A[p][q] == '#') return false;
  int i;
  if (x != p) {
    return (V[x][y] == V[p][y]);
  } else {
    return (H[x][y] == H[x][q]);
  }
}
bool bfs(pair<int, int> p, bool F[100100], int st) {
  int x = p.first;
  int y = p.second;
  bool flag = false;
  int len, i;
  char ch;
  bool fl = false;
  for (i = st; i < k; i++) {
    if (!F[i]) {
      fl = true;
      len = M[i].second;
      ch = M[i].first;
      if (ch == 'N') {
        if (x - len >= 0) {
          F[i] = true;
          if (Ax(x - len, y, x, y)) {
            flag = bfs(pair<int, int>(x - len, y), F, i + 1);
          }
          F[i] = false;
        }
      }
      if (ch == 'S') {
        if (x + len <= n - 1) {
          F[i] = true;
          if (Ax(x, y, x + len, y)) {
            flag = bfs(pair<int, int>(x + len, y), F, i + 1);
          }
          F[i] = false;
        }
      }
      if (ch == 'E') {
        if (y + len <= m - 1) {
          F[i] = true;
          if (Ax(x, y, x, y + len)) {
            flag = bfs(pair<int, int>(x, y + len), F, i + 1);
          }
          F[i] = false;
        }
      }
      if (ch == 'W') {
        if (y - len >= 0) {
          F[i] = true;
          if (Ax(x, y - len, x, y)) {
            flag = bfs(pair<int, int>(x, y - len), F, i + 1);
          }
          F[i] = false;
        }
      }
    }
    break;
  }
  if (st >= k) {
    return true;
  }
  return flag;
}
int main() {
  int i, j;
  char ch;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> ch;
      A[i][j] = ch;
      if (isalpha(ch)) {
        C.push_back(pair<int, int>(i, j));
      }
    }
  }
  for (i = 0; i < m; i++) {
    V[0][i] = (A[0][i] == '#');
    for (j = 1; j < n; j++) {
      V[j][i] = V[j - 1][i] + (A[j][i] == '#');
    }
  }
  for (i = 0; i < n; i++) {
    H[i][0] = (A[i][0] == '#');
    for (j = 0; j < m; j++) {
      H[i][j] = H[i][j - 1] + (A[i][j] == '#');
    }
  }
  int l;
  cin >> k;
  for (i = 0; i < k; i++) {
    cin >> ch;
    cin >> l;
    M.push_back(pair<int, int>(ch, l));
  }
  bool F[100100];
  bool flag = false;
  vector<char> str;
  bool res;
  for (i = 0; i < C.size(); i++) {
    memset(F, 0, sizeof(F));
    res = bfs(C[i], F, 0);
    if (res) {
      flag = true;
      str.push_back(A[C[i].first][C[i].second]);
    }
  }
  sort(str.begin(), str.end());
  if (flag) {
    for (i = 0; i < str.size(); i++) {
      cout << str[i];
    }
    cout << endl;
  } else
    cout << "no solution\n";
  return 0;
}
