#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m;
int can[N][N][4];
string grid[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> grid[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (j == 0)
        can[i][j][0] = 0;
      else {
        if (grid[i][j - 1] == '#')
          can[i][j][0] = 0;
        else
          can[i][j][0] = can[i][j - 1][0] + 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      if (j == m - 1)
        can[i][j][1] = 0;
      else {
        if (grid[i][j + 1] == '#')
          can[i][j][1] = 0;
        else
          can[i][j][1] = can[i][j + 1][1] + 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i == 0)
        can[i][j][2] = 0;
      else {
        if (grid[i - 1][j] == '#')
          can[i][j][2] = 0;
        else
          can[i][j][2] = can[i - 1][j][2] + 1;
      }
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (i == n - 1)
        can[i][j][3] = 0;
      else {
        if (grid[i + 1][j] == '#')
          can[i][j][3] = 0;
        else
          can[i][j][3] = can[i + 1][j][3] + 1;
      }
    }
  }
  vector<pair<char, int>> ope;
  int k;
  cin >> k;
  for (int i = 0; i < k; i++) {
    char x;
    int y;
    cin >> x >> y;
    ope.push_back(make_pair(x, y));
  }
  vector<char> ans;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] >= 'A' && grid[i][j] <= 'Z') {
        bool f = true;
        int nowx = i, nowy = j;
        int ind = 0;
        while (ind < k && f) {
          if (ope[ind].first == 'W') {
            if (can[nowx][nowy][0] < ope[ind].second) {
              f = false;
              break;
            }
            nowy -= ope[ind].second;
          }
          if (ope[ind].first == 'E') {
            if (can[nowx][nowy][1] < ope[ind].second) {
              f = false;
              break;
            }
            nowy += ope[ind].second;
          }
          if (ope[ind].first == 'N') {
            if (can[nowx][nowy][2] < ope[ind].second) {
              f = false;
              break;
            }
            nowx -= ope[ind].second;
          }
          if (ope[ind].first == 'S') {
            if (can[nowx][nowy][3] < ope[ind].second) {
              f = false;
              break;
            }
            nowx += ope[ind].second;
          }
          ind++;
          if (nowx < 0 || nowx >= n) f = false;
          if (nowy < 0 || nowy >= m) f = false;
        }
        if (f) ans.push_back(grid[i][j]);
      }
    }
  }
  sort(ans.begin(), ans.end());
  if (ans.size() == 0)
    cout << "no solution";
  else {
    for (auto x : ans) cout << x;
  }
  return 0;
}
