#include <bits/stdc++.h>
int mod = 1000000007;
using namespace std;
int n, m;
int row[2007][2007];
int col[2007][2007];
char grid[2007][2007];
map<char, int> mm;
vector<pair<long long, long long> > st;
int main() {
  mm['N'] = 0;
  mm['E'] = 1;
  mm['S'] = 2;
  mm['W'] = 3;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> grid[i][j];
      if (isalpha(grid[i][j])) st.push_back(make_pair(i, j));
    }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      row[i][j] = row[i][j - 1] + (int)(grid[i][j] == '#');
      col[i][j] = col[i - 1][j] + (int)(grid[i][j] == '#');
    }
  int q;
  cin >> q;
  vector<pair<long long, long long> > queries;
  while (q--) {
    char ch;
    int dis, dir;
    cin >> ch >> dis;
    dir = mm[ch];
    queries.push_back(make_pair(dir, dis));
  }
  string ans;
  for (int i = 0; i < st.size(); i++) {
    int x = st[i].first;
    int y = st[i].second;
    bool flag = 1;
    int xx = x, yy = y;
    for (int j = 0; j < queries.size(); j++) {
      int dir = queries[j].first;
      int dis = queries[j].second;
      int cnt = 0;
      switch (dir) {
        case 0:
          cnt = col[x][y] - col[x - dis - 1][y];
          x = x - dis;
          break;
        case 1:
          cnt = row[x][y + dis] - row[x][y - 1];
          y = y + dis;
          break;
        case 2:
          cnt = col[x + dis][y] - col[x - 1][y];
          x = x + dis;
          break;
        case 3:
          cnt = row[x][y] - row[x][y - dis - 1];
          y = y - dis;
          break;
      }
      if (cnt > 0 || x < 1 || x > n || y < 1 || y > m) {
        flag = 0;
        break;
      }
    }
    if (flag) ans.push_back(grid[xx][yy]);
  }
  sort(ans.begin(), ans.end());
  if (ans.empty()) ans = "no solution";
  cout << ans << "\n";
  return 0;
}
