#include <bits/stdc++.h>
using namespace std;
const int OO = (int)2e9;
const int MOD = (int)1e9 + 7;
const long double Pi = 3.1415926535897932384626433832795;
const int N = (int)2e2 + 5;
int a[10], b[10], cir[N][N], cnt[N * N][10], c[10], in[N][N], n, m, q,
    nc = 0, len, x, y, pos;
char s[N][N];
bool visit[N][N], inp[N][N];
pair<int, int> path[N * N];
string str;
bool ok;
bool out(int x, int y) { return (x < 1 || n < x || y < 1 || m < y); }
void dfs(int x, int y) {
  int z = x + a[s[x][y] - '0'], t = y + b[s[x][y] - '0'];
  visit[x][y] = true;
  path[++len] = pair<int, int>(x, y);
  inp[x][y] = true;
  if (out(z, t)) z = x, t = y;
  in[z][t]++;
  if (!visit[z][t])
    dfs(z, t);
  else if (inp[z][t]) {
    int st = 0;
    nc++;
    for (int i = (int)(1); i <= (int)(len); i++)
      if (path[i] == pair<int, int>(z, t)) {
        st = i;
        break;
      }
    for (int i = (int)(st); i <= (int)(len); i++) {
      cir[path[i].first][path[i].second] = nc;
      cnt[nc][s[path[i].first][path[i].second] - '0']++;
    }
  }
  inp[x][y] = false;
  len--;
}
void check(int x, int y) {
  visit[x][y] = true;
  if (ok) return;
  int z = x + a[s[x][y] - '0'], t = y + b[s[x][y] - '0'], cp;
  bool take = false;
  if (str[pos] == s[x][y]) c[str[pos++] - '0']--, take = true;
  if (pos == (int)(str.size())) {
    ok = true;
    return;
  }
  if (!out(z, t)) {
    if (cir[z][t]) {
      cp = cir[z][t];
      bool tmp = false;
      for (int i = (int)(0); i <= (int)(9); i++)
        tmp |= (c[i] > 0 && cnt[cp][i] == 0);
      if (!tmp) ok = true;
    } else
      check(z, t);
  }
  visit[x][y] = false;
  if (!ok && take) c[str[--pos] - '0']++;
}
int main() {
  cin >> n >> m >> q;
  for (int i = (int)(1); i <= (int)(n); i++) cin >> (s[i] + 1);
  for (int i = (int)(0); i <= (int)(9); i++) cin >> a[i] >> b[i];
  memset(visit, false, sizeof(visit));
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(m); j++)
      if (!visit[i][j]) dfs(i, j);
  memset(visit, false, sizeof(visit));
  while (q--) {
    cin >> str;
    memset(c, 0, sizeof(c));
    memset(visit, false, sizeof(visit));
    for (int i = (int)(0); i <= (int)((int)(str.size()) - 1); i++)
      c[str[i] - '0']++;
    ok = false;
    pos = 0;
    for (int i = (int)(1); i <= (int)(n); i++)
      for (int j = (int)(1); j <= (int)(m); j++)
        if (in[i][j] == 0) {
          if (ok) break;
          if (!visit[i][j]) check(i, j);
        }
    bool tmp;
    for (int i = (int)(1); i <= (int)(nc); i++) {
      tmp = false;
      for (int _ = (int)(0); _ <= (int)(9); _++)
        tmp |= (c[_] > 0 && cnt[i][_] == 0);
      if (!tmp) {
        ok = true;
        break;
      }
    }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO" << endl;
  }
}
