#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1111;
;
char num[maxn][maxn];
int v[maxn][maxn], h[maxn][maxn];
int n, m, q;
pair<char, int> mv[(int)1e5 + 10];
set<char> st;
set<char>::iterator it;
bool ok(int x, int y) {
  if (x < 1 || x > n) return false;
  if (y < 1 || y > m) return false;
  return num[x][y] != '#';
}
bool check(int x, int y) {
  for (int i = 0; i < q; i++) {
    int cnt = mv[i].second;
    if (mv[i].first == 'E') {
      if (!ok(x, y + cnt)) return false;
      if (v[x][y - 1] != v[x][y + cnt]) return false;
      y += cnt;
      continue;
    }
    if (mv[i].first == 'W') {
      if (!ok(x, y - cnt)) return false;
      if (v[x][y] != v[x][y - cnt - 1]) return false;
      y -= cnt;
      continue;
    }
    if (mv[i].first == 'N') {
      if (!ok(x - cnt, y)) return false;
      if (h[x][y] != h[x - cnt - 1][y]) return false;
      x -= cnt;
      continue;
    }
    if (mv[i].first == 'S') {
      if (!ok(x + cnt, y)) return false;
      if (h[x - 1][y] != h[x + cnt][y]) return false;
      x += cnt;
      continue;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) {
      cin >> num[i][j];
      v[i][j] = v[i][j - 1] + (num[i][j] == '#');
      h[i][j] = h[i - 1][j] + (num[i][j] == '#');
    }
  cin >> q;
  for (int i = 0; i < q; i++) {
    char a;
    int b;
    cin >> a >> b;
    mv[i] = make_pair(a, b);
  }
  for (int i = 1; i < n + 1; i++)
    for (int j = 1; j < m + 1; j++) {
      if (num[i][j] != '#' && num[i][j] != '.' && check(i, j)) {
        st.insert(num[i][j]);
      }
    }
  if (st.size() == 0) {
    cout << "no solution";
    return 0;
  }
  for (it = st.begin(); it != st.end(); it++) {
    cout << *it;
  }
}
