#include <bits/stdc++.h>
using namespace std;
const int MAX = 1005;
int N, M, K;
int board[MAX][MAX];
int mfor[MAX][MAX][4];
int mx[4] = {-1, 0, 1, 0}, my[4] = {0, 1, 0, -1};
int key(char c) {
  if (c == '#') return -1;
  if (c == '.') return 0;
  return (c - 'A' + 1);
}
int dir(char c) {
  if (c == 'N') return 0;
  if (c == 'E') return 1;
  if (c == 'S') return 2;
  if (c == 'W') return 3;
  assert(false);
  return -1;
}
void calcmfor() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (board[i][j] == -1) {
        mfor[i][j][0] = -1;
      } else {
        if (i == 0) {
          mfor[i][j][0] = 0;
        } else {
          mfor[i][j][0] = 1 + mfor[i + mx[0]][j + my[0]][0];
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = M - 1; j >= 0; j--) {
      if (board[i][j] == -1) {
        mfor[i][j][1] = -1;
      } else {
        if (j == M - 1) {
          mfor[i][j][1] = 0;
        } else {
          mfor[i][j][1] = 1 + mfor[i + mx[1]][j + my[1]][1];
        }
      }
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    for (int j = 0; j < M; j++) {
      if (board[i][j] == -1) {
        mfor[i][j][2] = -1;
      } else {
        if (i == N - 1) {
          mfor[i][j][2] = 0;
        } else {
          mfor[i][j][2] = 1 + mfor[i + mx[2]][j + my[2]][2];
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (board[i][j] == -1) {
        mfor[i][j][3] = -1;
      } else {
        if (j == 0) {
          mfor[i][j][3] = 0;
        } else {
          mfor[i][j][3] = 1 + mfor[i + mx[3]][j + my[3]][3];
        }
      }
    }
  }
}
void disp_board() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cout << board[i][j] << "\t";
    }
    cout << endl;
  }
  cout << endl;
}
void disp_mfor(int a) {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      cout << mfor[i][j][a] << "\t";
    }
    cout << endl;
  }
  cout << endl;
}
vector<int> ans;
vector<pair<int, int> > instr;
bool test(int x, int y) {
  int cx = x, cy = y;
  for (int i = 0; i < K; i++) {
    int cdir = instr[i].first, ccnt = instr[i].second;
    if (ccnt > mfor[cx][cy][cdir]) {
      return false;
    }
    cx += mx[cdir] * ccnt;
    cy += my[cdir] * ccnt;
  }
  return true;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    assert(s.length() == M);
    for (int j = 0; j < M; j++) {
      board[i][j] = key(s[j]);
    }
  }
  cin >> K;
  for (int i = 0; i < K; i++) {
    string a;
    int b;
    cin >> a >> b;
    instr.push_back(pair<int, int>(dir(a[0]), b));
  }
  calcmfor();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (board[i][j] > 0) {
        if (test(i, j)) {
          ans.push_back(board[i][j]);
        }
      }
    }
  }
  if (ans.size() > 0) {
    sort(ans.begin(), ans.end());
    for (int i = 0; i < ans.size(); i++) {
      cout << (char)(ans[i] + 'A' - 1);
    }
    cout << endl;
  } else {
    cout << "no solution\n";
  }
}
