#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void Read(T &x) {
  int f = 1;
  char t = getchar();
  while (t < '0' || t > '9') {
    if (t == '-') f = -1;
    t = getchar();
  }
  x = 0;
  while (t >= '0' && t <= '9') {
    x = x * 10 + t - '0';
    t = getchar();
  }
  x *= f;
}
const int maxn = 205;
const int maxe = 40005;
const int maxl = 1000005;
int n, m, q;
int all, loc[maxn][maxn];
int dx[11], dy[11];
char str[maxl], g[maxn][maxn];
struct graph {
  int fst[maxe], u[maxe << 1], v[maxe << 1], nxt[maxe], e_cn;
  int dfn[maxe], low[maxe], flag[maxe], belong[maxe], dfn_clock, sz;
  int line[maxe], deg[maxe], outdeg[maxe], size[maxe], now;
  bool alpha[maxe][10];
  graph() {
    sz = 0, e_cn = 0, now = 0, dfn_clock = 0;
    memset(deg, 0, sizeof(deg));
    memset(fst, 0, sizeof(fst));
    memset(dfn, 0, sizeof(dfn));
    memset(flag, 0, sizeof(flag));
    memset(alpha, 0, sizeof(alpha));
    memset(outdeg, 0, sizeof(outdeg));
  }
  void addedge(int x, int y) {
    e_cn++, u[e_cn] = x, v[e_cn] = y;
    nxt[e_cn] = fst[x], fst[x] = e_cn;
  }
  void tarjan(int cn) {
    line[++now] = cn;
    dfn[cn] = low[cn] = ++dfn_clock, flag[cn] = 2;
    for (register int i = fst[cn]; i; i = nxt[i]) {
      if (!dfn[v[i]]) {
        tarjan(v[i]);
        low[cn] = min(low[cn], low[v[i]]);
      } else if (flag[v[i]] == 2) {
        low[cn] = min(low[cn], dfn[v[i]]);
      }
    }
    if (dfn[cn] == low[cn]) {
      int cur;
      sz++;
      do {
        cur = line[now--];
        belong[cur] = sz;
        flag[cur] = 1;
        size[sz]++;
      } while (cur != cn);
    }
  }
  void rebuild(graph &res) {
    for (register int i = 1; i <= n; i++) {
      for (register int j = 1; j <= m; j++) {
        int to = belong[loc[i][j]];
        res.alpha[to][g[i][j]] = true;
      }
    }
    for (register int i = 1; i <= e_cn; i++) {
      int x = belong[u[i]], y = belong[v[i]];
      if (x != y) {
        res.addedge(x, y);
        res.outdeg[x]++, res.deg[y]++;
      }
    }
    res.sz = sz;
    for (register int i = 1; i <= sz; i++) res.size[i] = size[i];
  }
  bool match(char *str, int len) {
    for (register int i = 1; i <= all; i++) {
      if (deg[i] == 0) {
        int cn = i, now = 1;
        while (now <= len) {
          if (size[cn] > 1 || !outdeg[cn])
            while (alpha[cn][str[now] - '0'] && now <= len) now++;
          else if (alpha[cn][str[now] - '0'])
            now++;
          if (now > len) return true;
          if (!outdeg[cn]) break;
          for (register int p = fst[cn]; p; p = nxt[p]) cn = v[p];
        }
      }
    }
    return false;
  }
};
graph initgraph, revgraph;
void input() {
  int x, y;
  Read(n), Read(m), Read(q);
  for (register int i = 1; i <= n; i++) {
    scanf("%s", g[i] + 1);
    for (register int j = 1; j <= m; j++) g[i][j] -= '0';
  }
  for (register int i = 0; i < 10; i++) Read(dx[i]), Read(dy[i]);
}
void prepare() {
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= m; j++) {
      loc[i][j] = ++all;
    }
  }
  for (register int i = 1; i <= n; i++) {
    for (register int j = 1; j <= m; j++) {
      int dig = g[i][j];
      int tx = i + dx[dig], ty = j + dy[dig];
      if (tx >= 1 && tx <= n && ty >= 1 && ty <= m) {
        initgraph.addedge(loc[i][j], loc[tx][ty]);
      }
    }
  }
  for (register int i = 1; i <= all; i++) {
    if (!initgraph.dfn[i]) {
      initgraph.tarjan(i);
    }
  }
  initgraph.rebuild(revgraph);
}
void solve() {
  int len;
  while (q--) {
    scanf("%s", str + 1);
    len = strlen(str + 1);
    if (revgraph.match(str, len))
      printf("YES\n");
    else
      printf("NO\n");
  }
}
int main() {
  input();
  prepare();
  solve();
  return 0;
}
