#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int vx[11];
int vy[11];
int cyc[205][205];
int col[205][205];
char s[205][205];
vector<pair<int, int> > tr[205][205];
void dfs(int x, int y) {
  if (col[x][y] == 1) {
    int msk = 0;
    int cx, cy;
    cx = x;
    cy = y;
    while (true) {
      int dig = s[cx][cy] - '0';
      msk |= (1 << dig);
      if (cx + vx[dig] < n && cy + vy[dig] < m && cx + vx[dig] >= 0 &&
          cy + vy[dig] >= 0) {
        cx += vx[dig];
        cy += vy[dig];
      }
      if (cx == x && cy == y) break;
    }
    cx = x;
    cy = y;
    while (true) {
      int dig = s[cx][cy] - '0';
      cyc[cx][cy] = msk;
      if (cx + vx[dig] < n && cy + vy[dig] < m && cx + vx[dig] >= 0 &&
          cy + vy[dig] >= 0) {
        cx += vx[dig];
        cy += vy[dig];
      }
      if (cx == x && cy == y) break;
    }
    return;
  }
  if (col[x][y] == 2) return;
  col[x][y] = 1;
  cyc[x][y] = -1;
  int dig = s[x][y] - '0';
  int cx = x;
  int cy = y;
  if (cx + vx[dig] < n && cy + vy[dig] < m && cx + vx[dig] >= 0 &&
      cy + vy[dig] >= 0) {
    cx += vx[dig];
    cy += vy[dig];
  }
  tr[cx][cy].push_back(make_pair(x, y));
  dfs(cx, cy);
  col[x][y] = 2;
}
char word[1000005];
bool sol(int x, int y, int ind) {
  if (ind < 0) return true;
  if (col[x][y]) return false;
  col[x][y] = 1;
  if (cyc[x][y] != -1) {
    while (ind >= 0 && ((1 << (word[ind] - '0')) & cyc[x][y])) ind--;
  }
  if (ind < 0) return true;
  if (word[ind] == s[x][y]) ind--;
  if (ind < 0) return true;
  for (int j = 0; j < tr[x][y].size(); j++)
    if (sol(tr[x][y][j].first, tr[x][y][j].second, ind)) return true;
  return false;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < 10; i++) scanf("%d %d", vx + i, vy + i);
  memset(col, 0, sizeof(col));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dfs(i, j);
  for (int i = 0; i < q; i++) {
    scanf("%s", word);
    int len = strlen(word);
    memset(col, 0, sizeof(col));
    bool ok = false;
    for (int x = 0; x < n; x++)
      for (int y = 0; y < m; y++)
        if (cyc[x][y] != -1 && sol(x, y, len - 1)) ok = true;
    if (ok)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
