#include <bits/stdc++.h>
using namespace std;
int w[1000][1000], n[1000][1000], e[1000][1000], s[1000][1000];
char mp[1000][1000];
int N, M, K;
char ins[200000];
int l[200000];
bool check(int x, int y) {
  for (int i = 0; i < K; i++) {
    if (ins[i] == 'N') {
      if (n[x][y] < l[i]) return false;
      x -= l[i];
    } else if (ins[i] == 'E') {
      if (e[x][y] < l[i]) return false;
      y += l[i];
    } else if (ins[i] == 'S') {
      if (s[x][y] < l[i]) return false;
      x += l[i];
    } else {
      if (w[x][y] < l[i]) return false;
      y -= l[i];
    }
    if (mp[x][y] == '#') return false;
  }
  return true;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++) cin >> mp[i][j];
  for (int i = 1; i < N; i++)
    for (int j = 0; j < M; j++)
      if (mp[i - 1][j] == '#')
        n[i][j] = 0;
      else
        n[i][j] = n[i - 1][j] + 1;
  for (int j = M - 2; j >= 0; j--)
    for (int i = 0; i < N; i++)
      if (mp[i][j + 1] == '#')
        e[i][j] = 0;
      else
        e[i][j] = e[i][j + 1] + 1;
  for (int i = N - 2; i >= 0; i--)
    for (int j = 0; j < M; j++)
      if (mp[i + 1][j] == '#')
        s[i][j] = 0;
      else
        s[i][j] = s[i + 1][j] + 1;
  for (int j = 1; j < M; j++)
    for (int i = 0; i < N; i++)
      if (mp[i][j - 1] == '#')
        w[i][j] = 0;
      else
        w[i][j] = w[i][j - 1] + 1;
  cin >> K;
  for (int i = 0; i < K; i++) cin >> ins[i] >> l[i];
  vector<char> res;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      if (mp[i][j] != '.' && mp[i][j] != '#' && check(i, j))
        res.push_back(mp[i][j]);
  sort(res.begin(), res.end());
  for (int i = 0; i < res.size(); i++) cout << res[i];
  if (res.size() == 0) cout << "no solution";
  cout << endl;
  return 0;
}
