#include <bits/stdc++.h>
using namespace std;
int A[5000005], B[5000005], vis[5000005], in[5000005], q[5000005], G[5000005],
    r, to[5000005], dis[5000005], x, y, i, j, k, l, s, n, m, a[5000005];
int Q, tot;
struct node {
  int x, y;
} d[5000005];
char c[5000005];
inline int get(int x, int y) { return (x - 1) * m + y; }
inline void add(int x, int y) { dis[to[x] = y]++; }
inline void work(int x) {
  if (x == 14) x = 14;
  if (!in[x])
    in[x] = ++r, q[r] = x, vis[x] = 1;
  else {
    int S = 0;
    ++tot;
    for (int j = in[x]; j <= r; j++) S |= (1 << (a[q[j]])), A[q[j]] = tot;
    for (int j = 1; j < in[x]; j++) in[q[j]] = 0;
    r = 0;
    B[tot] = S;
    return;
  }
  if (!A[to[x]]) work(to[x]);
}
inline bool check(int x, int y) { return (y & x) == y; }
inline bool ask(int x) {
  int j = 1;
  while (!A[x]) {
    if ((c[j] - 48) == a[x]) j++;
    if (j > l) return true;
    x = to[x];
  }
  return check(B[A[x]], G[j]);
}
inline bool In(int x, int y) {
  if (x <= 0 || x > n || y <= 0 || y > m) return false;
  return true;
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      char C = getchar();
      while (C < '0' || C > '9') C = getchar();
      a[get(i, j)] = C - 48;
    }
  for (i = 0; i <= 9; i++) scanf("%d%d", &d[i].x, &d[i].y);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (In(i + d[a[get(i, j)]].x, j + d[a[get(i, j)]].y))
        add(get(i, j), get(i + d[a[get(i, j)]].x, j + d[a[get(i, j)]].y));
      else
        add(get(i, j), get(i, j));
    }
  tot = 0;
  for (i = 1; i <= n * m; i++)
    if (!dis[i]) work(i);
  for (i = 1; i <= n * m; i++)
    if (!vis[i]) work(i);
  for (i = 1; i <= Q; i++) {
    scanf("%s", c + 1);
    l = strlen(c + 1);
    int S = 0;
    G[l + 1] = 0;
    for (j = l; j; j--) G[j] = G[j + 1] | (1 << (c[j] - 48));
    bool bb = false;
    for (x = 1; x <= n; x++)
      for (y = 1; y <= m; y++) {
        if (!dis[get(x, y)])
          bb |= ask(get(x, y));
        else
          bb |= check(B[A[get(x, y)]], G[1]);
      }
    if (bb)
      puts("YES");
    else
      puts("NO");
  }
}
