#include <bits/stdc++.h>
using namespace std;
int n, m, q;
vector<int> cycle[40010], topo;
int G[40010], st[40010], stackPos[40010], t, wh[40010];
char c[210][210], ch[40010];
int a[10], b[10];
bool viz[40010];
int best[40010];
int conf[1000010];
int node(int i, int j) { return (i - 1) * m + j; }
bool outOfBounds(int x, int n) { return (x < 1 || x > n); }
void make_edge(int x, int y, int a, int b) {
  if (outOfBounds(x, n) || outOfBounds(y, m) || outOfBounds(a, n) ||
      outOfBounds(b, m))
    G[node(x, y)] = node(x, y);
  else
    G[node(x, y)] = node(a, b);
}
void dfs(int x) {
  viz[x] = 1;
  st[++t] = x;
  stackPos[x] = t;
  if (!viz[G[x]]) {
    dfs(G[x]);
  } else if (stackPos[G[x]]) {
    for (int i = t; i >= stackPos[G[x]]; --i) {
      wh[st[i]] = x;
      cycle[x].push_back(st[i]);
    }
  }
  --t;
  stackPos[x] = 0;
  if (wh[x] == 0 || wh[x] == x) {
    topo.push_back(x);
  }
}
int main() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < 10; ++i) {
    cin >> a[i] >> b[i];
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      make_edge(i, j, i + a[c[i][j] - '0'], j + b[c[i][j] - '0']);
      ch[node(i, j)] = c[i][j];
    }
  }
  int nodes = n * m;
  for (int i = 1; i <= nodes; ++i) {
    if (!viz[i]) dfs(i);
  }
  reverse(topo.begin(), topo.end());
  for (int i = 1; i <= q; ++i) {
    string s;
    cin >> s;
    for (int j = 1; j <= nodes; ++j) {
      best[j] = 0;
    }
    conf[s.size()] = 0;
    for (int j = s.size() - 1; j >= 0; --j) {
      conf[j] = conf[j + 1] | (1 << (s[j] - '0'));
    }
    bool ok = false;
    for (int j = 0; j < topo.size(); ++j) {
      int node = topo[j];
      if (wh[node]) {
        int current = 0;
        for (int k = 0; k < cycle[wh[node]].size(); ++k) {
          current |= (1 << (ch[cycle[wh[node]][k]] - '0'));
        }
        if ((current | conf[best[node]]) == current) {
          ok = true;
          break;
        }
      } else {
        if (s[best[node]] == ch[node]) best[node]++;
        best[G[node]] = max(best[G[node]], best[node]);
      }
    }
    if (ok)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
}
