#include <bits/stdc++.h>
using namespace std;
void maximiza(int &a, int b) { a = max(a, b); }
int n, m, q;
int t[300][300];
int nexti[10];
int nextj[10];
int visto[300][300];
int distbucle[300][300];
vector<int> conjbucle[300][300];
void siguiente(int i, int j, int &ni, int &nj) {
  ni = i + nexti[t[i][j]];
  nj = j + nextj[t[i][j]];
  if (ni < 0 or n - 1 < ni or nj < 0 or m - 1 < nj) {
    ni = i;
    nj = j;
  }
}
void calcula(int i, int j) {
  vector<pair<int, int> > lista;
  lista.push_back(pair<int, int>(i, j));
  visto[i][j] = 1;
  for (;;) {
    int nexti, nextj;
    siguiente(i, j, nexti, nextj);
    if (visto[nexti][nextj] == 1) {
      int pini = int(lista.size()) - 1;
      while (lista[pini].first != nexti or lista[pini].second != nextj) pini--;
      vector<int> conj(10, 0);
      for (int k = pini; k < int(lista.size()); k++) {
        distbucle[lista[k].first][lista[k].second] = 0;
        conj[t[lista[k].first][lista[k].second]] = 1;
      }
      for (int k = pini; k < int(lista.size()); k++)
        conjbucle[lista[k].first][lista[k].second] = conj;
      for (int k = pini - 1, d = 1; k >= 0; k--, d++) {
        distbucle[lista[k].first][lista[k].second] = d;
      }
      for (int k = 0; k < int(lista.size()); k++)
        visto[lista[k].first][lista[k].second] = 2;
      return;
    } else if (visto[nexti][nextj] == 2) {
      for (int k = int(lista.size()) - 1, d = distbucle[nexti][nextj] + 1;
           k >= 0; k--, d++) {
        distbucle[lista[k].first][lista[k].second] = d;
        visto[lista[k].first][lista[k].second] = 2;
      }
      return;
    }
    i = nexti;
    j = nextj;
    lista.push_back(pair<int, int>(i, j));
    visto[i][j] = 1;
  }
}
string s;
int posstring[300][300];
struct elem {
  int d;
  int i, j;
  elem() {}
  elem(int ind, int ini, int inj) {
    d = ind;
    i = ini;
    j = inj;
  }
};
bool operator<(elem e1, elem e2) { return e1.d < e2.d; }
bool incluido(int c, vector<int> &vc) {
  for (int b = 0; b < 10; b++)
    if ((c & (1 << b)) and vc[b] == 0) return false;
  return true;
}
int conjunto[2000000];
bool puede() {
  priority_queue<elem> q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      posstring[i][j] = 0;
      if (distbucle[i][j]) q.push(elem(distbucle[i][j], i, j));
    }
  }
  while (not q.empty()) {
    elem e = q.top();
    q.pop();
    int i = e.i;
    int j = e.j;
    int nextp = posstring[i][j];
    if (t[i][j] == s[nextp] - '0') nextp++;
    if (nextp > int(s.size())) return true;
    int nexti, nextj;
    siguiente(i, j, nexti, nextj);
    maximiza(posstring[nexti][nextj], nextp);
  }
  conjunto[int(s.size())] = 0;
  for (int i = int(s.size()) - 1; i >= 0; i--)
    conjunto[i] = conjunto[i + 1] | (1 << (s[i] - '0'));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (distbucle[i][j] == 0 and
          incluido(conjunto[posstring[i][j]], conjbucle[i][j]))
        return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      t[i][j] = c - '0';
    }
  }
  for (int k = 0; k < 10; k++) cin >> nexti[k] >> nextj[k];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (not visto[i][j]) calcula(i, j);
  for (int caso = 0; caso < q; caso++) {
    cin >> s;
    if (puede())
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
