#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MAXN = 205, MAXV = MAXN * MAXN, MAXS = 1e6 + 10;
int N, M, Q;
int A[MAXN][MAXN];
pii D[10];
char buf[MAXS];
vector<pii> adj[MAXN][MAXN], radj[MAXN][MAXN];
void addedge(pii x, pii y) {
  adj[x.first][x.second].push_back(y);
  radj[y.first][y.second].push_back(x);
}
int C;
vector<pii> nodes[MAXV];
vector<int> cadj[MAXV];
int bel[MAXN][MAXN];
bool vis[MAXN][MAXN];
int indeg[MAXV];
stack<pii> stk;
vector<pii> topo;
int has[MAXV];
void dfs1(pii x) {
  vis[x.first][x.second] = true;
  for (pii t : adj[x.first][x.second]) {
    if (!vis[t.first][t.second]) {
      dfs1(t);
    }
  }
  stk.push(x);
}
void dfs2(pii x) {
  vis[x.first][x.second] = false;
  bel[x.first][x.second] = C;
  nodes[C].push_back(x);
  has[C] |= (1 << A[x.first][x.second]);
  for (pii t : radj[x.first][x.second]) {
    if (vis[t.first][t.second]) {
      dfs2(t);
    }
  }
}
void find_scc() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (!vis[i][j]) {
        dfs1(pii(i, j));
      }
    }
  }
  while (!stk.empty()) {
    pii x = stk.top();
    stk.pop();
    if (vis[x.first][x.second]) {
      dfs2(x);
      C++;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int bij = bel[i][j];
      for (pii t : adj[i][j]) {
        int tij = bel[t.first][t.second];
        if (bij != tij) {
          cadj[bij].push_back(tij);
          indeg[tij]++;
        }
      }
    }
  }
}
int fst[10];
bool dfs(pii x, int pos, int len) {
  pos += (buf[pos] == A[x.first][x.second]);
  if (pos >= len + 1) {
    return true;
  }
  for (pii t : adj[x.first][x.second]) {
    if (dfs(t, pos, len)) {
      return true;
    }
  }
  return false;
}
bool go() {
  scanf("%s", buf + 1);
  int len = strlen(buf + 1);
  reverse(buf + 1, buf + len + 1);
  fill_n(fst, 10, len + 1);
  for (int i = len; i >= 1; i--) {
    fst[buf[i] -= '0'] = i;
  }
  for (int i = 0; i < C; i++) {
    if (indeg[i]) {
      continue;
    }
    int fbad = len + 1;
    for (int j = 0; j < 10; j++) {
      if (!(has[i] & (1 << j))) {
        fbad = min(fbad, fst[j]);
      }
    }
    if (fbad == len + 1) {
      return true;
    }
    for (int t : cadj[i]) {
      assert(nodes[t].size() == 1);
      pii x = nodes[t][0];
      if (dfs(x, fbad, len)) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
  }
  scanf("%d %d %d", &N, &M, &Q);
  for (int i = 0; i < N; i++) {
    getchar();
    for (int j = 0; j < M; j++) {
      A[i][j] = getchar() - '0';
    }
  }
  for (pii &p : D) {
    int x, y;
    scanf("%d %d", &x, &y);
    p = pii(x, y);
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      int val = A[i][j];
      int nx = i + D[val].first, ny = j + D[val].second;
      if (!(0 <= nx && nx < N && 0 <= ny && ny < M)) {
        nx = i;
        ny = j;
      }
      addedge(pii(nx, ny), pii(i, j));
    }
  }
  find_scc();
  for (int qi = 0; qi < Q; qi++) {
    puts(go() ? "YES" : "NO");
  }
}
