#include <bits/stdc++.h>
using namespace std;
int n, m, q, vis[202][202], circ_id[202][202], c_cnt, t[202][202], a[10], b[10],
    dp[202][202], circ[202 * 202];
char s[1000010];
bool debug = false;
vector<pair<int, int> > start;
bool out_bound(int i, int j) {
  if (0 <= i && i < n && 0 <= j && j < m) return false;
  return true;
}
pair<int, int> go_nxt(int i, int j) {
  int nxti = i + a[t[i][j]];
  int nxtj = j + b[t[i][j]];
  return out_bound(nxti, nxtj) ? make_pair(i, j) : make_pair(nxti, nxtj);
}
int find_msk(int i, int j) {
  circ_id[i][j] = c_cnt;
  int ans = 1 << t[i][j];
  pair<int, int> nxt = go_nxt(i, j);
  int curi = nxt.first;
  int curj = nxt.second;
  while (!(curi == i && curj == j)) {
    circ_id[curi][curj] = c_cnt;
    ans |= 1 << t[curi][curj];
    pair<int, int> nxt = go_nxt(curi, curj);
    curi = nxt.first;
    curj = nxt.second;
  }
  return ans;
}
int dfs(int i, int j) {
  pair<int, int> nxt = go_nxt(i, j);
  vis[i][j] = c_cnt;
  int nxti = nxt.first, nxtj = nxt.second;
  if (vis[nxti][nxtj] == -1)
    vis[i][j] = dfs(nxti, nxtj);
  else if (vis[nxti][nxtj] == c_cnt) {
    int msk = find_msk(i, j);
    circ[c_cnt++] = msk;
  } else
    vis[i][j] = vis[nxti][nxtj];
  return vis[i][j];
}
void init() {
  c_cnt = 0;
  memset(vis, -1, sizeof(vis));
  memset(circ_id, -1, sizeof(circ_id));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (vis[i][j] == -1) {
        start.push_back(make_pair(i, j));
        dfs(i, j);
      }
    }
}
bool check_loop(int curi, int curj) {
  bool flag = true;
  int msk = circ[circ_id[curi][curj]];
  for (int i = dp[curi][curj]; s[i]; i++) {
    if (!(msk & (1 << (s[i] - '0')))) {
      flag = false;
      break;
    }
  }
  return flag;
}
bool check() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dp[i][j] = -1;
  for (auto cur : start) {
    int curi = cur.first;
    int curj = cur.second;
    dp[curi][curj] = 0;
    while (!out_bound(curi, curj)) {
      if (circ_id[curi][curj] != -1) {
        if (check_loop(curi, curj)) return true;
        break;
      } else {
        int nxti = curi + a[t[curi][curj]];
        int nxtj = curj + b[t[curi][curj]];
        int nxt_v = dp[curi][curj] + (s[dp[curi][curj]] == t[curi][curj] + '0');
        if (s[nxt_v]) {
          if (dp[nxti][nxtj] < nxt_v)
            dp[nxti][nxtj] = nxt_v;
          else
            break;
        } else
          return true;
        curi = nxti;
        curj = nxtj;
      }
    }
  }
  return false;
}
int main(int argc, const char* argv[]) {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    char tmp[202];
    scanf("%s", tmp);
    for (int j = 0; j < m; j++) t[i][j] = tmp[j] - '0';
  }
  for (int i = 0; i < 10; i++) scanf("%d%d", &a[i], &b[i]);
  init();
  for (int i = 0; i < q; i++) {
    scanf("%s", s);
    printf("%s\n", check() ? "YES" : "NO");
  }
  return 0;
}
