#include<bits/stdc++.h>
using namespace std;
int n, m , k;
int s[100010][2];
char a[1010][1010] , b[1000010];
void xxy(char a , int b , int i) {
if(a == 'N') s[i][0] = -1 * b;
else if(a == 'S') s[i][0] = b;
else if(a == 'E') s[i][1] = b;
else if(a == 'W') s[i][1] = -1 * b;
}
bool check(int x , int y) {
return x >= 0 && x <= n - 1 && y >= 0 && y <= m - 1;
}
bool jojo(int x , int y) {
int tx = x;
int ty = y;
for(int i = 0;i < k;i++) {
if(check(tx + s[i][0] , ty + s[i][1]) && a[tx][ty] != '#') {
tx += s[i][0];
ty += s[i][1];
} else {
return false;
}
}
return true;
}
int main(){
cin >> n >> m;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
cin >> a[i][j];
}
}
cin >> k;
for(int i = 0;i < k;i++) {
char dir; int len;
cin >> dir >> len;
xxy(dir , len , i);
}
bool q = false;
int cnt = 0;
for(int i = 0;i < n;i++) {
for(int j = 0;j < m;j++) {
if(a[i][j] >= 'A' && a[i][j] <= 'Z') {
if(jojo(i , j)) {
b[cnt++] = a[i][j];
q = true;
}
}
}
}
sort(b , b + cnt);
for(int i = 0;i < cnt;i++) cout << b[i];
if(!q) cout << "no solution";
return 0;
}
30个点只过4个