#include <bits/stdc++.h>
using namespace std;
char board[201 * 201];
int next_field[201 * 201];
vector<vector<int>> edges;
int contained_in_cycle[201 * 201];
char word[1000002];
int a[11];
int b[11];
int m, n, q;
inline int idx(int i, int j) { return i * n + j; }
bool match(int start_node, int pos, char* word) {
  if (pos < 0) return true;
  bool found = false;
  for (auto node : edges[start_node]) {
    if (contained_in_cycle[node] != -1) continue;
    if (word[pos] == board[node]) {
      found = match(node, pos - 1, word);
    } else {
      found = match(node, pos, word);
    }
    if (found) break;
  }
  return found;
}
void init_edges() {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      int ij = idx(i, j);
      int ni = i + a[board[ij]];
      int nj = j + b[board[ij]];
      if (ni < 0 || nj < 0 || ni >= m || nj >= n) {
        ni = i;
        nj = j;
      }
      next_field[ij] = idx(ni, nj);
      vector<int> v;
      edges.push_back(v);
    }
  }
}
void init_rev_edges() {
  for (int i = 0; i < m * n; i++) {
    edges[next_field[i]].push_back(i);
  }
}
void mark_cycles() {
  char visited[m * n];
  memset(visited, 0, sizeof(bool) * m * n);
  memset(contained_in_cycle, -1, sizeof(int) * m * n);
  for (int i = 0; i < n * m; ++i) {
    if (visited[i]) continue;
    int curr = i;
    vector<int> seen_new;
    while (!visited[curr]) {
      visited[curr] = 1;
      seen_new.push_back(curr);
      curr = next_field[curr];
    }
    int cycle_start = -1;
    for (auto node : seen_new) {
      if (node == curr) {
        cycle_start = node;
        break;
      }
    }
    if (cycle_start == -1) continue;
    int mask = 0;
    curr = cycle_start;
    do {
      mask |= (1 << board[curr]);
      curr = next_field[curr];
    } while (curr != cycle_start);
    contained_in_cycle[cycle_start] = mask;
  }
}
int main() {
  scanf("%d %d %d", &m, &n, &q);
  char tmp[201];
  for (int i = 0; i < m; ++i) {
    scanf(" %s", tmp);
    for (int j = 0; j < n; ++j) {
      board[idx(i, j)] = tmp[j] - '0';
    }
  }
  for (int i = 0; i < 10; ++i) {
    scanf("%d %d", &a[i], &b[i]);
  }
  init_edges();
  mark_cycles();
  init_rev_edges();
  for (int i = 0; i < q; ++i) {
    scanf(" %s", word);
    int len = strlen(word);
    int last[10];
    memset(last, -1, sizeof(int) * 10);
    for (int i = 0; i < len; i++) {
      word[i] -= '0';
      last[word[i]] = i;
    }
    bool found = false;
    for (int start = 0; start < n * m; ++start) {
      if (contained_in_cycle[start] == -1) continue;
      int pos = -1;
      for (int d = 0; d <= 9; d++) {
        if ((contained_in_cycle[start] & (1 << d)) == 0) {
          pos = max(pos, last[d]);
        }
      }
      found = match(start, pos, word);
      if (found) break;
    }
    cout << (found ? "YES" : "NO") << endl;
  }
  return 0;
}
