#include <bits/stdc++.h>
using namespace std;
int n, m, k, t, c;
string arr[1010];
vector<char> ans;
char di;
vector<pair<char, int> > op;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) cin >> arr[i];
  scanf("%d", &k);
  while (k--) {
    scanf(" %c %d", &di, &t);
    op.push_back(make_pair(di, t));
  }
  int num[n][m][4];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < 4; k++) num[i][j][k] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < m; j++) {
      if (arr[i][j] != '#' && arr[i][j - 1] != '#')
        num[i][j][0] += (num[i][j - 1][0] + 1);
    }
    for (int j = m - 2; j >= 0; j--) {
      if (arr[i][j] != '#' && arr[i][j + 1] != '#')
        num[i][j][1] += (num[i][j + 1][1] + 1);
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 1; i < n; i++) {
      if (arr[i][j] != '#' && arr[i - 1][j] != '#')
        num[i][j][2] += (num[i - 1][j][2] + 1);
    }
    for (int i = n - 2; i >= 0; i--) {
      if (arr[i][j] != '#' && arr[i + 1][j] != '#')
        num[i][j][3] += (num[i + 1][j][3] + 1);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] != '#' && arr[i][j] != '.') {
        bool flag = false;
        int x = i, y = j;
        for (int k = 0; k < (int)op.size(); k++) {
          di = op[k].first;
          t = op[k].second;
          if (di == 'W' && num[x][y][0] >= t)
            y -= t;
          else if (di == 'E' && num[x][y][1] >= t)
            y += t;
          else if (di == 'N' && num[x][y][2] >= t)
            x -= t;
          else if (di == 'S' && num[x][y][3] >= t)
            x += t;
          else {
            flag = true;
            break;
          }
        }
        if (!flag) ans.push_back(arr[i][j]);
      }
    }
  }
  if (ans.size() == 0)
    printf("no solution\n");
  else {
    sort(ans.begin(), ans.end());
    for (int i = 0; i < (int)ans.size(); i++) cout << ans[i];
    cout << endl;
  }
  return 0;
}
