#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n, m;
char a[1010][1010];
int k;
int dir[101000];
int len[101000];
int col[1010][1010];
int row[1010][1010];
void precalc() {
  for (int i = 0; i < n; ++i) {
    row[i][0] = (a[i][0] == '#');
    for (int j = 1; j < m; ++j) {
      row[i][j] = row[i][j - 1] + (a[i][j] == '#');
    }
  }
  for (int j = 0; j < m; ++j) {
    col[j][0] = (a[0][j] == '#');
    for (int i = 1; i < n; ++i) {
      col[j][i] = col[j][i - 1] + (a[i][j] == '#');
    }
  }
}
int colsum(int j, int i0, int i1) {
  if (i0 > i1) swap(i0, i1);
  int ret = col[j][i1];
  if (i0 > 0) ret -= col[j][i0 - 1];
  return ret;
}
int rowsum(int i, int j0, int j1) {
  if (j0 > j1) swap(j0, j1);
  int ret = row[i][j1];
  if (j0 > 0) ret -= row[i][j0 - 1];
  return ret;
}
int sum(int i0, int j0, int i1, int j1) {
  if (i0 == i1) return rowsum(i0, j0, j1);
  return colsum(j0, i0, i1);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  scanf("%d", &k);
  for (int i = 0; i < k; ++i) {
    char c;
    getchar();
    scanf("%c %d", &c, &len[i]);
    if (c == 'W') dir[i] = 2;
    if (c == 'E') dir[i] = 3;
    if (c == 'N') dir[i] = 0;
    if (c == 'S') dir[i] = 1;
  }
  precalc();
  string res;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (a[i][j] >= 'A' && a[i][j] <= 'Z') {
        int i0 = i;
        int j0 = j;
        bool ok = true;
        for (int r = 0; r < k; ++r) {
          int i1 = i0 + dx[dir[r]] * len[r];
          int j1 = j0 + dy[dir[r]] * len[r];
          if (i1 < 0 || i1 >= n && j1 < 0 || j1 >= m) {
            ok = false;
            break;
          }
          if (sum(i0, j0, i1, j1) != 0) {
            ok = false;
            break;
          }
          i0 = i1;
          j0 = j1;
        }
        if (ok) res += a[i][j];
      }
    }
  }
  sort(res.begin(), res.end());
  if (res == "")
    cout << "no solution";
  else
    cout << res;
  return 0;
}
