#include <bits/stdc++.h>
using namespace std;
int deg[205][205], a[10], b[10], n, m, cycnum, cyc[205][205], q, x, y, len, mtc,
    t, i, j, k, c1[205][205], c2[205][205], vis[205][205], syc;
bool cycle[40105][10];
char d[205][205], str[1000005];
bool gez[205][205];
void dfs(int x, int y) {
  syc++;
  int x2, y2;
  x2 = x, y2 = y;
  int x1, y1;
  x1 = x, y1 = y;
  while (1) {
    if (gez[x][y]) break;
    gez[x][y] = true;
    vis[x][y] = syc;
    int x5, y5;
    x5 = x + a[d[x][y]];
    y5 = y + b[d[x][y]];
    if (x5 >= 1 and x5 <= n and y5 >= 1 and y5 <= m) x = x5, y = y5;
  }
  if (vis[x][y] and vis[x][y] < syc) {
    x2 = c1[x][y];
    y2 = c2[x][y];
    do {
      c1[x1][y1] = x2;
      c2[x1][y1] = y2;
      int x4, y4;
      x4 = x1 + a[d[x1][y1]];
      y4 = y1 + b[d[x1][y1]];
      if (x4 >= 1 and x4 <= n and y4 >= 1 and y4 <= m) x1 = x4, y1 = y4;
    } while (x1 != x and y1 != y);
    return;
  }
  if (cyc[x][y]) return;
  cycnum++;
  x1 = x, y1 = y;
  do {
    cyc[x1][y1] = cycnum;
    cycle[cycnum][d[x1][y1]] = true;
    int x3, y3;
    x3 = x1 + a[d[x1][y1]];
    y3 = y1 + b[d[x1][y1]];
    if (x3 >= 1 and x3 <= n and y3 >= 1 and y3 <= m) x1 = x3, y1 = y3;
  } while (x1 != x or y1 != y);
}
bool solve(int x, int y) {
  mtc = 1;
  int i, j, cy;
  while (1) {
    gez[x][y] = true;
    if (cyc[x][y]) break;
    if (str[mtc] == d[x][y]) mtc++;
    int x1, y1;
    x1 = x + a[d[x][y]];
    y1 = y + b[d[x][y]];
    if (x1 >= 1 and x1 <= n and y1 >= 1 and y1 <= m) x = x1, y = y1;
  }
  cy = cyc[x][y];
  for (; mtc <= len; mtc++)
    if (!cycle[cy][str[mtc]]) return 0;
  printf("YES\n");
  return 1;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf(" %c", &d[i][j]);
      d[i][j] -= '0';
    }
  for (i = 0; i < 10; i++) scanf("%d %d", &a[i], &b[i]);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      x = i, y = j;
      x += a[d[i][j]];
      y += b[d[i][j]];
      if (x >= 1 and x <= n and y >= 1 and y <= m) deg[x][y]++;
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (!deg[i][j]) dfs(i, j);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (!gez[i][j]) dfs(i, j);
  for (t = 1; t <= q; t++) {
    memset(gez, 0, sizeof gez);
    scanf("%s", str + 1);
    len = strlen(str + 1);
    for (i = 1; i <= len; i++) str[i] -= '0';
    bool res = 0;
    for (i = 1; i <= n and !res; i++)
      for (j = 1; j <= m and !res; j++)
        if (!deg[i][j]) res = solve(i, j);
    if (res) continue;
    for (i = 1; i <= n and !res; i++)
      for (j = 1; j <= m and !res; j++)
        if (!gez[i][j]) res = solve(i, j);
    if (res) continue;
    printf("NO\n");
  }
  return 0;
}
