#include <bits/stdc++.h>
int dr4[] = {1, 0, -1, 0}, dc4[] = {0, -1, 0, 1};
int dr8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dc8[] = {0, -1, -1, -1, 0, 1, 1, 1};
using namespace std;
int n, m, q, dx[10], dy[10], nxt[205 * 205][10];
bool vis[205][205];
char s[205][205], tmp[1000009];
vector<int> start;
int pos(int x, int y) { return x * m + y; }
bool valid(int xx, int yy) { return (xx >= 0 && xx < n && yy >= 0 && yy < m); }
void dfs(int x, int y) {
  vis[x][y] = 1;
  int u = pos(x, y);
  int d = s[x][y] - '0';
  int xx = x + dx[d], yy = y + dy[d];
  if (valid(xx, yy)) {
    int v = pos(xx, yy);
    nxt[u][d] = v;
    if (!vis[xx][yy]) dfs(xx, yy);
    for (int i = 0; i < 10; i++) {
      if (i != d) nxt[u][i] = nxt[v][i];
    }
  } else
    nxt[u][d] = u;
}
bool query() {
  for (int i = 0; i < start.size(); i++) {
    int u = start[i];
    int len = strlen(tmp);
    for (int j = 0; j < len && u != -1; j++) {
      int nx = tmp[j] - '0';
      u = nxt[u][nx];
    }
    if (u != -1) return 1;
  }
  return 0;
}
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < 10; i++) cin >> dx[i] >> dy[i];
  memset(nxt, -1, sizeof nxt);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vis[i][j]) continue;
      dfs(i, j);
      start.push_back(pos(i, j));
    }
  }
  for (int i = 0; i < q; i++) {
    scanf("%s", tmp);
    if (query())
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
