#include <bits/stdc++.h>
using namespace std;
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  s << "{";
  for (int i = 0; i < t.size(); i++)
    s << t[i] << (i == t.size() - 1 ? "" : ",");
  return s << "}" << endl;
}
string d[1001];
char kier[200000];
int len[200000];
int sumx[1001][1001];
int sumy[1001][1001];
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> d[i];
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) cin >> kier[i] >> len[i];
  for (int i = 0; i < n; i++) {
    sumx[i][0] = 0;
    for (int j = 1; j <= m; j++)
      sumx[i][j] = sumx[i][j - 1] + (d[i][j - 1] != '#');
  }
  for (int i = 0; i < m; i++) {
    sumy[i][0] = 0;
    for (int j = 1; j <= n; j++)
      sumy[i][j] = sumy[i][j - 1] + (d[j - 1][i] != '#');
  }
  vector<char> ok;
  for (int i1 = 0; i1 < n; i1++)
    for (int i2 = 0; i2 < m; i2++) {
      if (!isupper(d[i1][i2])) continue;
      int a = i1, b = i2;
      int sm;
      bool zle = 0;
      for (int j = 0; j < k; j++) {
        if (kier[j] == 'N') {
          if (a - len[j] < 0) {
            zle = 1;
            break;
          }
          sm = sumy[b][a] - sumy[b][a - len[j]];
          if (sm != len[j]) {
            zle = 1;
            break;
          }
          a = a - len[j];
          ;
        }
        if (kier[j] == 'S') {
          if (a + len[j] >= n) {
            zle = 1;
            break;
          }
          sm = sumy[b][a + len[j] + 1] - sumy[b][a + 1];
          if (sm != len[j]) {
            zle = 1;
            break;
          }
          a = a + len[j];
        }
        if (kier[j] == 'E') {
          if (b + len[j] >= m) {
            zle = 1;
            break;
          }
          sm = sumx[a][b + len[j] + 1] - sumx[a][b + 1];
          if (sm != len[j]) {
            zle = 1;
            break;
          }
          b = b + len[j];
        }
        if (kier[j] == 'W') {
          if (b - len[j] < 0) {
            zle = 1;
            break;
          }
          sm = sumx[a][b] - sumx[a][b - len[j]];
          if (sm != len[j]) {
            zle = 1;
            break;
          }
          b = b - len[j];
        };
      }
      if (!zle) ok.push_back(d[i1][i2]);
    }
  sort((ok).begin(), (ok).end());
  if (!ok.size())
    cout << "no solution";
  else {
    for (int j = 0; j < ok.size(); j++) cout << ok[j];
  }
  return 0;
}
