#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long powm(long long base, long long exp, long long mod = 1000000007) {
  base %= mod;
  long long ans = 1;
  while (exp) {
    if (exp & 1LL) ans = (ans * base) % mod;
    exp >>= 1LL, base = (base * base) % mod;
  }
  return ans;
}
vector<char> ans;
string s[1001];
vector<pair<char, long long>> p;
int l[1001][1001], r[1001][1001], u[1001][1001], d[1001][1001];
void check(int x, int y) {
  int tx = x, ty = y;
  for (int i = 0; i < p.size(); i++) {
    char c = p[i].first;
    int len = p[i].second;
    switch (c) {
      case 'N':
        if (len > u[x][y]) return;
        x -= len;
        break;
      case 'S':
        if (len > d[x][y]) return;
        x += len;
        break;
      case 'E':
        if (len > r[x][y]) return;
        y += len;
        break;
      case 'W':
        if (len > l[x][y]) return;
        y -= len;
        break;
    }
  }
  ans.push_back(s[tx][ty]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> s[i];
  long long k;
  cin >> k;
  for (long long i = 0; i < k; i++) {
    char t;
    int a;
    cin >> t >> a;
    p.push_back({t, a});
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (s[i][j] == '#') {
        l[i][j] = -1;
        u[i][j] = -1;
        continue;
      }
      if (j != 0)
        l[i][j] = l[i][j - 1] + 1;
      else
        l[i][j] = 0;
      if (i != 0)
        u[i][j] = u[i - 1][j] + 1;
      else
        u[i][j] = 0;
    }
  }
  for (long long i = n - 1; i >= 0; i--) {
    for (long long j = m - 1; j >= 0; j--) {
      if (s[i][j] == '#') {
        r[i][j] = -1;
        d[i][j] = -1;
        continue;
      }
      if (j != m - 1)
        r[i][j] = r[i][j + 1] + 1;
      else
        r[i][j] = 0;
      if (i != n - 1)
        d[i][j] = d[i + 1][j] + 1;
      else
        d[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] >= 'A' && s[i][j] <= 'Z') check(i, j);
  sort(ans.begin(), ans.end());
  if (ans.size() == 0) cout << "no solution" << '\n';
  for (auto it : ans) cout << it;
}
