#include <bits/stdc++.h>
using namespace std;
int n, m, q;
char s2[10000006];
char s[205][205];
int vis[205][205];
int dp[205 * 205][20];
int dx[10];
int dy[10];
vector<int> Q;
int id(int x, int y) { return x * m + y; }
void dfs(int x, int y) {
  vis[x][y] = 1;
  int t = (s[x][y] - '0'), p = id(x, y);
  int xx = x + dx[t], yy = y + dy[t];
  if (xx < 0 || xx >= n || yy < 0 || yy >= m)
    dp[p][t] = p;
  else {
    int v = id(xx, yy);
    dp[p][t] = id(xx, yy);
    if (vis[xx][yy] == 0) dfs(xx, yy);
    for (int i = 0; i < 10; i++)
      if (i != t) dp[p][i] = dp[v][i];
  }
}
int check(char s2[]) {
  int len = strlen(s2);
  for (int i = 0; i < Q.size(); i++) {
    int x = Q[i];
    for (int j = 0; j < len; j++) {
      x = dp[x][s2[j] - '0'];
      if (x < 0) break;
    }
    if (x >= 0) return 1;
  }
  return 0;
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < 10; i++) scanf("%d%d", &dx[i], &dy[i]);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j]) {
        dfs(i, j);
        Q.push_back(id(i, j));
      }
    }
  }
  for (int i = 0; i < q; i++) {
    scanf("%s", s2);
    if (check(s2))
      printf("YES\n");
    else
      puts("NO");
  }
}
