#include <bits/stdc++.h>
using namespace std;
int num(int i, int j);
int s[200][200];
int road[200][200] = {0};
int dp[40000][10];
int a[10], b[10];
int fuck[40000];
int n, m, q;
int shit;
string s2;
int dfs(int i, int j);
int check();
int wide(int i, int j);
int main() {
  std::ios::sync_with_stdio(false);
  string f;
  cin >> n >> m >> q;
  memset(dp, -1, sizeof(dp));
  int i, j, k;
  shit = 0;
  for (i = 0; i < n; i++) {
    cin >> f;
    for (j = 0; j < m; j++) {
      s[i][j] = f[j] - '0';
    }
  }
  for (i = 0; i < 10; i++) cin >> a[i] >> b[i];
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++)
      if (road[i][j] == 0) {
        dfs(i, j);
        fuck[shit] = i * m + j;
        shit++;
      }
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) {
      if (road[i][j] == 1) wide(i, j);
    }
  for (k = 0; k < q; k++) {
    cin >> s2;
    check();
  }
}
int check() {
  int i, j, h, k, g;
  j = m * n;
  int leng = s2.length();
  for (i = 0; i < shit; i++) {
    g = fuck[i];
    for (h = 0; h < leng; h++) {
      g = dp[g][s2[h] - '0'];
      if (g < 0) break;
    }
    if (g >= 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
int wide(int i, int j) {
  road[i][j] = 2;
  int x, y;
  int p, q, r, t;
  p = num(i, j);
  q = s[i][j];
  x = i + a[q];
  y = j + b[q];
  if (0 <= x && 0 <= y && x < n && y < m) {
    r = num(x, y);
    if (road[x][y] == 1) wide(x, y);
    for (t = 0; t < 10; t++)
      if (t != q) dp[p][t] = dp[r][t];
  } else {
    ;
  }
  return 1;
}
int dfs(int i, int j) {
  road[i][j] = 1;
  int x, y;
  int p, q, r, t;
  p = num(i, j);
  q = s[i][j];
  x = i + a[q];
  y = j + b[q];
  if (0 <= x && 0 <= y && x < n && y < m) {
    r = num(x, y);
    dp[p][q] = r;
    if (road[x][y] == 0) dfs(x, y);
    for (t = 0; t < 10; t++)
      if (t != q) dp[p][t] = dp[r][t];
  } else {
    dp[p][q] = p;
  }
  return 1;
}
int num(int i, int j) { return i * m + j; }
