#include <bits/stdc++.h>
using namespace std;
int H, W, Q;
string S, T;
int DY[10], DX[10];
int nex[202 * 202];
int inloop[202 * 202];
int vis[202 * 202];
int mask[202 * 202];
vector<int> st;
vector<int> E[202 * 202];
int first[10];
int dfs(int cur, int first) {
  vis[cur] = first;
  if (vis[nex[cur]] == first) {
    st.push_back(nex[cur]);
    inloop[cur] = nex[cur];
    mask[inloop[cur]] |= 1 << S[cur];
    if (inloop[cur] == cur) return -1;
    return inloop[cur];
  } else if (vis[nex[cur]] >= 0) {
    return -1;
  } else {
    inloop[cur] = dfs(nex[cur], first);
    mask[inloop[cur]] |= 1 << S[cur];
    if (inloop[cur] == -1 || inloop[cur] == cur) return -1;
    return inloop[cur];
  }
}
bool dfs2(int cur, int pos) {
  if (S[cur] == T[pos]) pos++;
  if (pos >= T.size()) return true;
  for (auto& r : E[cur])
    if (dfs2(r, pos)) return true;
  return false;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> H >> W >> Q;
  for (i = 0; i < H; i++) cin >> s, S += s;
  for (auto& r : S) r -= '0';
  for (i = 0; i < 10; i++) cin >> DY[i] >> DX[i];
  for (y = 0; y < H; y++)
    for (x = 0; x < W; x++) {
      int nx = x + DX[S[y * W + x]];
      int ny = y + DY[S[y * W + x]];
      if (nx < 0 || nx >= W || ny < 0 || ny >= H) nx = x, ny = y;
      nex[y * W + x] = ny * W + nx;
    }
  H *= W;
  memset(vis, 0xff, sizeof(vis));
  memset(inloop, 0xff, sizeof(inloop));
  for (i = 0; i < H; i++)
    if (vis[i] == -1) dfs(i, i);
  for (i = 0; i < H; i++)
    if (inloop[i] == -1) {
      x = nex[i];
      if (inloop[x] >= 0) x = inloop[x];
      E[x].push_back(i);
    }
  while (Q--) {
    cin >> T;
    reverse((T.begin()), (T.end()));
    for (i = 0; i < 10; i++) first[i] = T.size();
    for (i = 0; i < T.size(); i++) {
      T[i] -= '0';
      first[T[i]] = min(first[T[i]], i);
    }
    for (auto& r : st) {
      int mi = T.size();
      for (i = 0; i < 10; i++)
        if ((mask[r] & (1 << i)) == 0) mi = min(mi, first[i]);
      if (mi == T.size() || dfs2(r, mi)) {
        cout << "YES" << endl;
        goto out;
      }
    }
    cout << "NO" << endl;
  out:;
  }
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false);
  for (i = 0; i < argc - 1; i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < s.size(); i++) ungetc(s[s.size() - 1 - i], stdin);
  solve();
  return 0;
}
