#include <bits/stdc++.h>
using namespace std;
const int N = 205;
char s[1000005];
int n, m, T, cnt, res, f[N * N][10], c[N][N], p[N][N], vis[N][N], a[10], b[10],
    ans[N * N], d[N * N];
void dfs(int x, int y) {
  int xx = x + a[c[x][y]], yy = y + b[c[x][y]];
  if (xx < 1 || xx > n || yy < 1 || yy > m)
    f[p[x][y]][c[x][y]] = p[x][y];
  else {
    f[p[x][y]][c[x][y]] = p[xx][yy];
    if (!vis[xx][yy]) {
      vis[xx][yy] = 1;
      dfs(xx, yy);
    }
    for (int i = 0; i < 10; i++)
      if (i != c[x][y]) f[p[x][y]][i] = f[p[xx][yy]][i];
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &T);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= m; j++) {
      c[i][j] = s[j] - '0';
      p[i][j] = ++cnt;
      d[cnt] = c[i][j];
    }
  }
  for (int i = 0; i < 10; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!vis[i][j]) {
        vis[i][j] = 1;
        ans[++res] = p[i][j];
        dfs(i, j);
      }
  while (T--) {
    scanf("%s", s + 1);
    bool flag = 0;
    for (int i = 1; i <= res; i++) {
      int x = ans[i], l = strlen(s + 1);
      for (int j = 1; j <= l; j++) {
        x = f[x][s[j] - '0'];
        if (x <= 0) break;
      }
      if (x) {
        flag = 1;
        break;
      }
    }
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
