#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5;
struct edge {
  int from, to;
  int next;
} e[maxn];
int head[maxn], tot;
int ind[222 * 222];
void add(int a, int b) {
  ind[b]++;
  e[tot].from = a, e[tot].to = b, e[tot].next = head[a], head[a] = tot++;
}
char gra[222][222];
int a[11], b[11];
bool vis[222 * 222];
int n, m, q;
int stx[222 * 222], sty[222 * 222];
int len[222 * 222];
char s[1000005];
int dfs(int rt) {
  int x = rt / m, y = rt % m;
  vis[rt] = 1;
  for (int i = head[rt]; i != -1; i = e[i].next) {
    int to = e[i].to;
    return 1 + dfs(to);
  }
  return 1;
}
bool hasc[222 * 222][10];
void dfs1(int rt, int id) {
  int x = rt / m, y = rt % m;
  vis[rt] = 1;
  hasc[id][gra[x][y] - '0'] = 1;
  for (int i = head[rt]; i != -1; i = e[i].next) {
    int to = e[i].to;
    if (vis[to]) return;
    dfs1(to, id);
  }
}
int main() {
  while (~scanf("%d%d%d", &n, &m, &q)) {
    for (int i = 0; i < n; i++) {
      scanf("%s", gra[i]);
    }
    for (int i = 0; i < 10; i++) scanf("%d%d", &a[i], &b[i]);
    memset(vis, 0, sizeof(vis));
    memset(ind, 0, sizeof(ind));
    memset(head, -1, sizeof(head));
    tot = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int id = gra[i][j] - '0';
        int ni = i + a[id], nj = j + b[id];
        if (ni == i && nj == j) continue;
        if (ni < 0 || nj < 0 || ni >= n || nj >= m) continue;
        add(i * m + j, ni * m + nj);
      }
    }
    int cnt = 0, maxlen = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (ind[i * m + j] == 0) {
          len[cnt] = dfs(i * m + j);
          maxlen = max(maxlen, len[cnt]);
          stx[cnt] = i;
          sty[cnt++] = j;
        }
      }
    }
    int cntc = 0;
    memset(hasc, 0, sizeof(hasc));
    cntc = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (vis[i * m + j]) continue;
        dfs1(i * m + j, cntc);
        cntc++;
      }
    }
    while (q--) {
      scanf("%s", s);
      int len = strlen(s);
      bool ok = 0;
      char tpid = s[len - 1];
      int tplen = len - 1;
      while (tpid == s[tplen] && tplen > 0) tplen--;
      int p;
      for (int i = 0; i < cnt; i++) {
        p = 0;
        int nowx = stx[i], nowy = sty[i];
        int now = nowx * m + nowy;
        while (head[now] != -1) {
          if (s[p] == gra[now / m][now % m]) p++;
          now = e[head[now]].to;
        }
        if (s[p] == gra[now / m][now % m]) p++;
        if (p >= len) {
          ok = 1;
          break;
        }
        if (p > tplen && tpid == gra[now / m][now % m]) {
          ok = 1;
          break;
        }
      }
      if (ok) {
        printf("YES\n");
        continue;
      }
      bool has[11];
      memset(has, 0, sizeof(has));
      for (int i = 0; i < len; i++) {
        has[s[i] - '0'] = 1;
      }
      for (int i = 0; i < cntc; i++) {
        bool flag = 1;
        for (int j = 0; j < 10; j++) {
          if (has[j] && !hasc[i][j]) {
            flag = 0;
            break;
          }
        }
        if (flag) {
          ok = 1;
          break;
        }
      }
      if (ok) {
        printf("YES\n");
        continue;
      }
      printf("NO\n");
    }
  }
}
