#include <bits/stdc++.h>
using namespace std;
string s[234];
int n, m, q;
int dx[12], dy[12];
int on_cycle[123456 + 1];
int digit[123456 + 1];
int to[123456 + 1];
vector<int> a[123456 + 1];
string S;
int last[123456 + 1];
bool found;
bool vis[123456 + 1];
void dfs(int u, int pos) {
  if (pos < 0) {
    found = true;
    return;
  }
  if (found) return;
  for (int i = 0; i < a[u].size(); i++) {
    int v = a[u][i];
    if (on_cycle[v] != -1) continue;
    dfs(v, pos - (digit[v] == S[pos] - '0'));
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i <= 9; i++) cin >> dx[i] >> dy[i];
  memset(vis, false, sizeof(vis));
  memset(on_cycle, -1, sizeof(on_cycle));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x = i + dx[s[i][j] - '0'];
      int y = j + dy[s[i][j] - '0'];
      if (x < 0 || x >= n || y < 0 || y >= m) {
        x = i;
        y = j;
      }
      to[i * m + j] = x * m + y;
      digit[i * m + j] = s[i][j] - '0';
    }
  n = n * m;
  for (int i = 0; i < n; i++) {
    a[to[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    int p = i;
    vector<int> cycle;
    while (!vis[p]) {
      cycle.push_back(p);
      vis[p] = true;
      p = to[p];
    }
    int ps = -1;
    for (int j = 0; j < (int)cycle.size(); j++)
      if (p == cycle[j]) {
        ps = j;
        break;
      }
    int mask = 0;
    for (int j = ps; j < cycle.size(); j++) mask |= (1 << digit[cycle[j]]);
    for (int j = ps; j < cycle.size(); j++) on_cycle[cycle[j]] = mask;
  }
  for (int i = 1; i <= q; i++) {
    cin >> S;
    for (int j = 0; j <= 9; j++) last[j] = -1;
    for (int j = 0; j < S.size(); j++) last[S[j] - '0'] = j;
    found = false;
    for (int j = 0; j < n; j++) {
      int pos = -1;
      if (on_cycle[j] == -1) continue;
      for (int d = 0; d <= 9; d++) {
        if (on_cycle[j] & (1 << d)) continue;
        pos = max(pos, last[d]);
      }
      dfs(j, pos);
    }
    if (found)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
