#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const int MAX = 250;
int N;
vector<int> G[MAXN];
int dfstime[MAXN], low[MAXN], in_stack[MAXN], SCC[MAXN], sccnum, dfsnum;
int stackk[MAXN + 5], pop;
void scc(int node) {
  dfstime[node] = low[node] = ++dfsnum;
  stackk[pop++] = node;
  in_stack[node] = 1;
  for (int i = 0; i < G[node].size(); i++) {
    int v = G[node][i];
    if (!dfstime[v]) {
      scc(v);
      low[node] = min(low[node], low[v]);
    } else if (in_stack[v])
      low[node] = min(low[node], dfstime[v]);
  }
  if (dfstime[node] == low[node]) {
    sccnum++;
    while (in_stack[node]) {
      int x = stackk[--pop];
      in_stack[x] = 0;
      SCC[x] = sccnum;
    }
  }
}
void find_scc() {
  sccnum = dfsnum = pop = 0;
  for (int i = 0; i < N; i++) {
    if (!dfstime[i]) scc(i);
  }
}
int d[MAX][MAX];
int movX[10], movY[10];
int n, m;
bool can_move(int i, int j) { return (i >= 0 && j >= 0 && i < n && j < m); }
bool gd[MAXN][10];
vector<int> g[MAXN];
int sorted[MAXN], add_first;
int mk1[MAXN], mk2[MAXN];
bool cycles;
void topsort(int v) {
  mk1[v] = 1;
  mk2[v] = 1;
  for (int i = 0; i < g[v].size() && !cycles; i++) {
    int u = g[v][i];
    if (mk2[u])
      cycles = true;
    else if (!mk1[u])
      topsort(u);
  }
  mk2[v] = 0;
  sorted[add_first--] = v;
}
void TOPSORT() {
  for (int i = 1; i <= sccnum && !cycles; i++)
    if (!mk1[i]) topsort(i);
}
int dp[MAXN];
bool ok(vector<int> &s, bool *gd, int pos) {
  for (int i = 0; i < 10; i++) {
    if (!gd[i] && s[i] > pos) {
      return false;
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int q;
  cin >> n >> m >> q;
  string auxx;
  for (int i = 0; i < n; i++) {
    cin >> auxx;
    for (int j = 0; j < m; j++) {
      d[i][j] = auxx[j] - '0';
    }
  }
  for (int i = 0; i < 10; i++) {
    cin >> movX[i] >> movY[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x = i + movX[d[i][j]];
      int y = j + movY[d[i][j]];
      if (can_move(x, y)) {
        int u = i * m + j;
        int v = x * m + y;
        G[u].push_back(v);
      }
    }
  }
  N = n * m;
  find_scc();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x = i + movX[d[i][j]];
      int y = j + movY[d[i][j]];
      int u = SCC[i * m + j];
      gd[u][d[i][j]] = true;
      if (can_move(x, y)) {
        int v = x * m + y;
        if (u != SCC[v]) {
          v = SCC[v];
          g[u].push_back(v);
        }
      }
    }
  }
  add_first = MAXN - 1;
  TOPSORT();
  while (q--) {
    for (int i = 0; i <= sccnum; i++) {
      dp[i] = -1;
    }
    string w;
    cin >> w;
    vector<int> s[w.size()];
    for (int i = 0; i < w.size(); i++) {
      s[i].clear();
      for (int j = 0; j < 10; j++) {
        s[i].push_back(-1);
        if (i > 0) {
          s[i][j] = s[i - 1][j];
        }
      }
      s[i][w[i] - '0'] = i;
    }
    int maxpos = -1;
    for (int i = add_first + 1; i < MAXN; i++) {
      int u = sorted[i];
      int pos = dp[u];
      int ini = pos + 1;
      int fin = w.size() - 1;
      while (ini <= fin) {
        int mid = (ini + fin) / 2;
        if (ok(s[mid], gd[u], pos)) {
          pos = mid;
          ini = mid + 1;
        } else {
          fin = mid - 1;
        }
      }
      dp[u] = pos;
      for (int j = 0; j < g[u].size(); j++) {
        int v = g[u][j];
        dp[v] = max(dp[u], dp[v]);
      }
      maxpos = max(maxpos, dp[u]);
    }
    if (maxpos == w.size() - 1) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
