#include <bits/stdc++.h>
using namespace std;
pair<int, int> ch[28];
string arr[1005] = {};
vector<pair<char, int>> v;
int n, m, k, rowse[1005][1005] = {}, colss[1005][1005] = {},
             rowsw[1005][1005] = {}, colsn[1005][1005] = {};
bool ongrid(int x, int y, int q, int prvx, int prvy) {
  if (x >= 0 && x < n && y >= 0 && y < m) {
    if (q == 1) {
      return (!abs(colsn[x][y] - colsn[prvx][prvy]));
    } else if (q == 2) {
      return (!abs(colss[x][y] - colss[prvx][prvy]));
    } else if (q == 3) {
      return (!abs(rowsw[x][y] - rowsw[prvx][prvy]));
    } else {
      return (!abs(rowse[x][y] - rowse[prvx][prvy]));
    }
  } else
    return false;
}
bool dfs(int x, int y, int cur) {
  if (cur >= k) return 1;
  int dx = v[cur].second;
  if (v[cur].first == 'N') {
    if (!ongrid(x - dx, y, 1, x, y)) return 0;
    return dfs(x - dx, y, cur + 1);
  } else if (v[cur].first == 'S') {
    if (!ongrid(x + dx, y, 2, x, y)) return 0;
    return dfs(x + dx, y, cur + 1);
  } else if (v[cur].first == 'W') {
    if (!ongrid(x, y - dx, 3, x, y)) return 0;
    return dfs(x, y - dx, cur + 1);
  } else {
    if (!ongrid(x, y + dx, 4, x, y)) return 0;
    return dfs(x, y + dx, cur + 1);
  }
}
int main() {
  ios::sync_with_stdio(0), ios_base::sync_with_stdio(0), cin.tie(0),
      cout.tie(0);
  ;
  cin >> n >> m;
  for (int i = 0; i <= 26; ++i) ch[i] = {-1, -1};
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    for (int j = 0; j < m; ++j) {
      rowse[i][j] += (arr[i][j] == '#');
      if (arr[i][j] != '.' && arr[i][j] != '#') {
        ch[arr[i][j] - 'A'] = {i, j};
      }
      if (!j) continue;
      rowse[i][j] += rowse[i][j - 1];
    }
    for (int j = m - 1; j >= 0; --j) {
      rowsw[i][j] += (arr[i][j] == '#');
      rowsw[i][j] += rowsw[i][j + 1];
    }
  }
  for (int j = 0; j < m; ++j) {
    for (int i = 0; i < n; ++i) {
      colss[i][j] += (arr[i][j] == '#');
      if (!i) continue;
      colss[i][j] += colss[i - 1][j];
    }
    for (int i = n - 1; i >= 0; --i) {
      colsn[i][j] += (arr[i][j] == '#');
      colsn[i][j] += colsn[i + 1][j];
    }
  }
  cin >> k;
  for (int i = 0; i < k; ++i) {
    char d;
    int l;
    cin >> d >> l;
    v.push_back({d, l});
  }
  string s;
  for (int i = 0; i <= 26; ++i) {
    if (ch[i].first == ch[i].second && ch[i].first == -1) continue;
    if (dfs(ch[i].first, ch[i].second, 0)) s.push_back((char)(i + 'A'));
  }
  if (s.empty()) return cout << "no solution\n", 0;
  cout << s << "\n";
  return 0;
}
