#include <bits/stdc++.h>
const int N = 209;
const int S = N * N;
const int SIGMA = 10;
const int L = 1000009;
int n, m, q;
int col[N][N];
int a[SIGMA], b[SIGMA];
int to[S];
int st[S];
int top, tot, time_f;
int dfn[S], low[S];
bool in[S];
int bel[S];
bool c[S][SIGMA];
std::vector<int> e[S];
int f[S];
char s[L];
int id(int x, int y) { return (x - 1) * m + y; }
void init() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf("%1d", &col[i][j]);
  for (int i = 0; i < SIGMA; ++i) scanf("%d%d", a + i, b + i);
}
int color(int x) { return col[(x - 1) / m + 1][(x - 1) % m + 1]; }
void dfs(int now) {
  in[now] = true, st[++top] = now;
  dfn[now] = low[now] = ++time_f;
  if (to[now]) {
    if (!dfn[to[now]]) {
      dfs(to[now]);
      low[now] = std::min(low[now], low[to[now]]);
    } else if (in[to[now]])
      low[now] = std::min(low[now], dfn[to[now]]);
  }
  if (dfn[now] == low[now]) {
    int p;
    ++tot;
    do {
      p = st[top--];
      in[p] = false, bel[p] = tot;
      c[tot][color(p)] = true;
    } while (p != now);
  }
}
int dp(int i) {
  if (f[i] != -1) return f[i];
  f[i] = n;
  for (int t = 0; t < (int)(e[i]).size(); ++t) {
    int j = e[i][t];
    f[i] = std::min(f[i], dp(j));
  }
  while (f[i] && c[i][s[f[i]] - '0']) f[i]--;
  return f[i];
}
void solve() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      int ti = i + a[col[i][j]], tj = j + b[col[i][j]];
      if (1 <= ti && ti <= n && 1 <= tj && tj <= m) to[id(i, j)] = id(ti, tj);
    }
  for (int i = 1; i <= n * m; ++i)
    if (!dfn[i]) dfs(i);
  for (int i = 1; i <= n * m; ++i)
    if (to[i] && bel[i] != bel[to[i]]) e[bel[i]].push_back(bel[to[i]]);
  while (q--) {
    bool flag = false;
    scanf("%s", s + 1), n = strlen(s + 1);
    std::fill(f + 1, f + tot + 1, -1);
    for (int i = 1; i <= tot; ++i)
      if (f[i] == -1 && dp(i) == 0) {
        puts("YES"), flag = true;
        break;
      }
    if (!flag) puts("NO");
  }
}
int main() {
  init();
  solve();
  return 0;
}
