#include <bits/stdc++.h>
using namespace std;
long long n, m;
char grid[1001][1001];
long long k;
char dirs[100001];
long long lens[100001];
int _left[1001][1001], top[1001][1001];
bool check(int r, int c, int q) {
  if (q == k) return true;
  int r1 = r, c1 = c;
  if (dirs[q] == 'N') {
    r1 -= lens[q];
    if (r1 < 0) return false;
    int cnt = (r1 > 0) ? top[r][c] - top[r1 - 1][c] : top[r][c];
    if (cnt > 0) return false;
  }
  if (dirs[q] == 'S') {
    r1 += lens[q];
    if (r1 >= n) return false;
    int cnt = (r > 0) ? top[r1][c] - top[r - 1][c] : top[r1][c];
    if (cnt > 0) return false;
  }
  if (dirs[q] == 'W') {
    c1 -= lens[q];
    if (c1 < 0) return false;
    int cnt = (c1 > 0) ? _left[r][c] - _left[r][c1 - 1] : _left[r][c];
    if (cnt > 0) return false;
  }
  if (dirs[q] == 'E') {
    c1 += lens[q];
    if (c1 >= m) return false;
    int cnt = (c > 0) ? _left[r][c1] - _left[r][c - 1] : _left[r][c1];
    if (cnt > 0) return false;
  }
  return check(r1, c1, q + 1);
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      grid[i][j] = s[j];
    }
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    char x;
    long long y;
    cin >> x >> y;
    dirs[i] = x;
    lens[i] = y;
  }
  for (int i = 0; i < n; i++) {
    _left[i][0] = (grid[i][0] == '#') ? 1 : 0;
    for (int j = 1; j < m; j++) {
      _left[i][j] = (grid[i][j] == '#') ? 1 : 0;
      _left[i][j] += _left[i][j - 1];
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      top[i][j] = (grid[i][j] == '#') ? 1 : 0;
      if (i > 0) top[i][j] += top[i - 1][j];
    }
  }
  string res = "";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] != '.' && grid[i][j] != '#') {
        bool a = check(i, j, 0);
        if (a) res.push_back(grid[i][j]);
      }
    }
  }
  sort(res.begin(), res.end());
  if (res.empty())
    cout << "no solution" << endl;
  else
    cout << res << endl;
}
int main() {
  long long q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
