#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int A[201][201];
int nX[10], nY[10], deg[40000], bel[40000];
vector<vector<int> > G, R;
vector<vector<int> > C;
vector<pair<int, int> > Starts;
bool check(int i, int j) { return i >= 0 && i < m && j >= 0 && j < n; }
stack<int> S;
int d[40000], f[40000];
void dfs(int v) {
  d[v] = 1;
  S.push(v);
  bel[v] = v;
  if (!G[v].size()) Starts.push_back(pair<int, int>(v, 0));
  for (int i = (0); i < (int)(G[v].size()); ++i) {
    int u = G[v][i];
    if (d[u] && !f[u]) {
      int mask = 0;
      C.push_back(vector<int>());
      while (C.back().empty() || C.back().back() != u) {
        C.back().push_back(S.top());
        mask |= (1 << A[S.top() / n][S.top() % n]);
        bel[S.top()] = u;
        S.pop();
      }
      for (int j = (0); j < (int)(C.back().size()); ++j) {
        int k = C.back()[j];
        Starts.push_back(pair<int, int>(k, mask));
      }
    } else if (!d[u])
      dfs(u);
  }
  f[v] = 1;
  if (S.size() && S.top() == v) S.pop();
}
void input() {
  cin >> m >> n >> q;
  char in;
  for (int i = (0); i < (int)(m); ++i)
    for (int j = (0); j < (int)(n); ++j) {
      cin >> in;
      A[i][j] = in - '0';
    }
  for (int i = (0); i < (int)(10); ++i) cin >> nX[i] >> nY[i];
  G.assign(n * m, vector<int>());
  R.assign(n * m, vector<int>());
  for (int i = (0); i < (int)(m); ++i)
    for (int j = (0); j < (int)(n); ++j) {
      int k = i + nX[A[i][j]], l = j + nY[A[i][j]];
      if (!check(k, l)) continue;
      G[i * n + j].push_back(k * n + l);
      R[k * n + l].push_back(i * n + j);
    }
  for (int i = (0); i < (int)(m * n); ++i)
    if (!d[i]) dfs(i);
}
vector<int> pos;
string q_s;
bool dfs_query(int v) {
  while (pos[v] < q_s.length() && A[v / n][v % n] == q_s[pos[v]] - '0')
    ++pos[v];
  if (pos[v] == q_s.length()) return 1;
  for (int i = (0); i < (int)(R[v].size()); ++i) {
    int u = R[v][i];
    if (bel[u] == bel[v]) continue;
    pos[u] = pos[v];
    if (dfs_query(u)) return 1;
  }
  return 0;
}
bool query(string& s) {
  pos.assign(n * m, 0);
  reverse(s.begin(), s.end());
  q_s = s;
  for (int i = (0); i < (int)(Starts.size()); ++i) {
    int cur = 0, mask = 0;
    while ((cur < s.length()) && (((mask | (1 << (s[cur] - '0'))) |
                                   Starts[i].second) == Starts[i].second)) {
      mask = (mask | (1 << (s[cur] - '0')));
      ++cur;
    }
    int jump = Starts[i].first;
    pos[jump] = cur;
    if (dfs_query(jump)) return 1;
  }
  return false;
}
void process_queries() {
  string s;
  while (q--) {
    cin >> s;
    printf("%s\n", (query(s) ? "YES" : "NO"));
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  input();
  process_queries();
}
