#include <bits/stdc++.h>
using namespace std;
const int N = 205;
const int P = N * N;
const int Len = 1000005;
int n, m, q, p, dx[10], dy[10];
int Col[P];
char Str[N][N], S[Len];
struct Gedge {
  int u, v;
} G[P];
int Cnt;
int lines, front[P];
struct Edge {
  int next, to;
} E[P];
inline void addline(int x, int y) {
  E[++lines] = (Edge){front[x], y};
  front[x] = lines;
}
inline int miro(int x, int y) { return x * m + y + 1; }
bool Dat[P][10];
int ing[P], Start[P];
namespace Shrink_Point {
int Time, dfn[P], low[P];
int top, sta[P], ins[P], loc[P];
void Dfs(int u) {
  dfn[u] = low[u] = ++Time;
  ins[sta[++top] = u] = true;
  for (int i = front[u], v; i != 0; i = E[i].next) {
    if (!dfn[v = E[i].to]) {
      Dfs(v);
      low[u] = min(low[u], low[v]);
    } else if (ins[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    while (sta[top] != u) {
      loc[sta[top]] = u;
      ins[sta[top]] = false;
      top--;
    }
    ins[loc[u] = u] = false;
    top--;
  }
}
void Tarjan() {
  for (int i = 1; i <= Cnt; i++) addline(G[i].u, G[i].v);
  for (int i = 1; i <= p; i++)
    if (!dfn[i]) Dfs(i);
  memset(front, 0, sizeof(front));
  lines = 0;
  for (int i = 1; i <= Cnt; i++) {
    int u = loc[G[i].u], v = loc[G[i].v];
    if (u != v) addline(v, u), ing[u]++;
  }
  for (int i = 1; i <= p; i++) Dat[loc[i]][Col[i]] = true;
  for (int i = 1; i <= p; i++)
    if (loc[i] == i && !ing[i]) Start[++*Start] = i;
}
};  // namespace Shrink_Point
namespace String_Automata {
bool Dfs(int u, char *S, int pos) {
  while (pos >= 0 && Dat[u][S[pos] - 48]) pos--;
  if (pos < 0) return true;
  for (int i = front[u], v; i != 0; i = E[i].next) {
    if (Dfs(v = E[i].to, S, pos)) return true;
  }
  return false;
}
void Query() {
  scanf("%s", S);
  int len = strlen(S) - 1;
  for (int i = 1; i <= *Start; i++)
    if (Dfs(Start[i], S, len)) {
      printf("YES\n");
      return;
    }
  printf("NO\n");
}
};  // namespace String_Automata
int main() {
  scanf("%d%d%d\n", &n, &m, &q);
  p = n * m;
  for (int i = 0; i <= n - 1; i++) scanf("%s", Str[i]);
  for (int i = 0; i <= 9; i++) scanf("%d %d", &dx[i], &dy[i]);
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= m - 1; j++) {
      int u = miro(i, j), c = Col[u] = Str[i][j] - 48;
      int tx = i + dx[c], ty = j + dy[c];
      if (min(tx, ty) < 0 or tx >= n or ty >= m) continue;
      G[++Cnt] = (Gedge){u, miro(tx, ty)};
    }
  using namespace Shrink_Point;
  Tarjan();
  using namespace String_Automata;
  for (int i = 1; i <= q; i++) Query();
  return 0;
}
