#include <bits/stdc++.h>
using namespace std;
int N, M, Q, v, c;
string line;
char ch;
char A[1100][1100];
vector<pair<int, int> > op;
int DX[1100], DY[1100];
int U[1100][1100], D[1100][1100], L[1100][1100], R[1100][1100];
void process() {
  for (long long x = 0; x < N; x++)
    for (long long y = 0; y < M; y++)
      if (A[x][y] == '#')
        U[x][y] = 0;
      else
        U[x][y] = U[x - 1][y] + 1;
  for (long long y = 0; y < M; y++)
    for (long long x = 0; x < N; x++)
      if (A[x][y] == '#')
        L[x][y] = 0;
      else
        L[x][y] = L[x][y - 1] + 1;
  for (long long x = N - 1; x >= 0; x--)
    for (long long y = 0; y < M; y++)
      if (A[x][y] == '#')
        D[x][y] = 0;
      else
        D[x][y] = D[x + 1][y] + 1;
  for (long long y = M - 1; y >= 0; y--)
    for (long long x = 0; x < N; x++)
      if (A[x][y] == '#')
        R[x][y] = 0;
      else
        R[x][y] = R[x][y + 1] + 1;
}
bool ok;
bool inside(int x, int y) {
  for (typeof((op).begin()) it = (op).begin(); it != (op).end(); it++) {
    ch = it->first;
    c = it->second;
    if (ch == 'N') {
      if (U[x][y] < c + 1) return false;
      x -= c;
    }
    if (ch == 'S') {
      if (D[x][y] < c + 1) return false;
      x += c;
    }
    if (ch == 'W') {
      if (L[x][y] < c + 1) return false;
      y -= c;
    }
    if (ch == 'E') {
      if (R[x][y] < c + 1) return false;
      y += c;
    }
  }
  ok = true;
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (long long I = 0; I < N; I++) cin >> A[I];
  process();
  cin >> Q;
  while (Q--) {
    cin >> line >> v;
    op.push_back(pair<int, int>(line[0], v));
  }
  string sol = "";
  for (long long I = 0; I < N; I++)
    for (long long K = 0; K < M; K++)
      if (A[I][K] != '#' && A[I][K] != '.' && inside(I, K)) sol += A[I][K];
  sort((sol).begin(), (sol).end());
  if (!ok)
    cout << "no solution" << endl;
  else
    cout << sol << endl;
}
