#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "{" << p.first << "," << p.second << "}";
  return os;
}
const int N = 1e3 + 5;
const int M = 1e5 + 5;
const int oo = 1e9 + 7;
string s[N];
char dir[M];
int len[M];
int q1[N][N];
int q2[N][N];
int row(int i, int x, int y) {
  if (y < x) swap(x, y);
  return q1[i][y] - q1[i][x - 1];
}
int col(int j, int x, int y) {
  if (y < x) swap(x, y);
  return q2[y][j] - q2[x - 1][j];
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = "%" + s[i];
  }
  int k;
  cin >> k;
  for (int i = 1; i <= k; i++) cin >> dir[i] >> len[i];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) q1[i][j] += q1[i][j - 1] + (s[i][j] == '#');
  }
  for (int j = 1; j <= m; j++) {
    for (int i = 1; i <= n; i++) {
      q2[i][j] += q2[i - 1][j] + (s[i][j] == '#');
    }
  }
  string ans;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i][j] >= 'A' and s[i][j] <= 'Z') {
        int x = i, y = j;
        bool pos = 1;
        for (int i = 1; i <= k and pos; i++) {
          int xx =
              x + (dir[i] == 'S' ? len[i] : 0) - (dir[i] == 'N' ? len[i] : 0);
          int yy =
              y + (dir[i] == 'E' ? len[i] : 0) - (dir[i] == 'W' ? len[i] : 0);
          pos = 1 <= xx and xx <= n and 1 <= yy and yy <= m;
          if (pos) {
            if (xx == x) {
              pos = row(x, yy, y) == 0;
            } else {
              pos = col(y, xx, x) == 0;
            }
          }
          x = xx;
          y = yy;
        }
        if (pos) ans.push_back(s[i][j]);
      }
    }
  }
  sort(ans.begin(), ans.end());
  if (ans.empty()) ans = "no solution";
  cout << ans << "\n";
}
