#include <bits/stdc++.h>
using namespace std;
char num[205][205], str[1000005];
int n, m, q, A[205], B[205], de[205][205];
struct node {
  int x, y;
} nxt[205][205];
int ringid, id[205][205], mark[205][205], px, py;
vector<node> chain[205 * 205];
int use[12][205 * 205], isring[205][205];
void dfs(int x, int y, int k) {
  if (mark[x][y] == k) {
    id[x][y] = ++ringid;
    px = x, py = y;
    return;
  }
  if (mark[x][y] != 0) return;
  mark[x][y] = k;
  int X = nxt[x][y].x, Y = nxt[x][y].y;
  dfs(X, Y, k);
  id[x][y] = id[X][Y];
  if (px && py) isring[x][y] = use[num[x][y] - '0'][id[x][y]] = 1;
  if (px == x && py == y) px = py = 0;
}
bool check(int len) {
  for (int i = 1; i <= ringid; i++) {
    int r = len;
    while (r > 0 && use[str[r] - '0'][i]) r--;
    if (r == 0) return 1;
    for (int j = 0; j < chain[i].size(); j++) {
      int l = 1, x = chain[i][j].x, y = chain[i][j].y;
      while (l <= r && isring[x][y] == 0) {
        if (str[l] == num[x][y]) l++;
        int X = nxt[x][y].x, Y = nxt[x][y].y;
        x = X, y = Y;
      }
      if (l > r) return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%s", num[i] + 1);
  for (int i = 0; i < 10; i++) scanf("%d%d", &A[i], &B[i]);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = i + A[num[i][j] - '0'];
      int y = j + B[num[i][j] - '0'];
      if (x >= 1 && x <= n && y >= 1 && y <= m)
        nxt[i][j] = (node){x, y}, de[x][y]++;
      else
        nxt[i][j] = (node){i, j};
    }
  }
  int tp = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      dfs(i, j, ++tp);
      if (de[i][j] == 0) chain[id[i][j]].push_back((node){i, j});
    }
  while (q--) {
    scanf("%s", str + 1);
    if (check(strlen(str + 1)))
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
