#include <bits/stdc++.h>
using namespace std;
int p[1000 + 5][1000 + 5];
char c[1000 + 5][1000 + 5];
vector<char> ans;
vector<pair<int, int> > pos;
vector<pair<char, int> > go;
int get_sum(int l1, int r1, int l2, int r2) {
  if (l1 > l2) swap(l1, l2);
  if (r1 > r2) swap(r1, r2);
  return p[l2][r2] - p[l1 - 1][r2] - p[l2][r1 - 1] + p[l1 - 1][r1 - 1];
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] >= 'A' && c[i][j] <= 'Z') {
        pos.push_back({i, j});
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1];
      if (c[i][j] == '#') p[i][j]++;
    }
  }
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    char t;
    int r;
    cin >> t >> r;
    go.push_back({t, r});
  }
  for (auto o : pos) {
    int l = o.first;
    int r = o.second;
    bool can = true;
    for (auto i : go) {
      int l1 = l;
      int r1 = r;
      if (i.first == 'N') l1 -= i.second;
      if (i.first == 'S') l1 += i.second;
      if (i.first == 'W') r1 -= i.second;
      if (i.first == 'E') r1 += i.second;
      if (l1 <= 0 || l1 > n || r1 <= 0 || r1 > m) {
        can = false;
        break;
      }
      if (get_sum(l, r, l1, r1) > 0) {
        can = false;
        break;
      }
      l = l1;
      r = r1;
    }
    if (can) {
      ans.push_back(c[o.first][o.second]);
    }
  }
  sort(ans.begin(), ans.end());
  if (ans.empty()) {
    cout << "no solution";
    return 0;
  }
  for (auto i : ans) {
    cout << i;
  }
  return 0;
}
