#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool umax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<pair<int, int> > adj[209][209], inv[209][209];
int deg[209][209], MASK[209][209], dx[11], dy[11], dp[209][209], DP[1000009];
char arr[209][209], s[1000009];
bool h[209][209], mark[209][209], vis[209][209];
void flood(int x, int y, int mask) {
  if (h[x][y]) return;
  MASK[x][y] = mask;
  h[x][y] = true;
  for (__typeof((adj[x][y]).begin()) it = (adj[x][y]).begin();
       it != (adj[x][y]).end(); it++)
    flood(it->first, it->second, mask);
}
void dfs(int x, int y, int mask) {
  if (mark[x][y]) {
    flood(x, y, mask);
    return;
  }
  mark[x][y] = true;
  mask |= (1 << (arr[x][y] - '0'));
  for (__typeof((adj[x][y]).begin()) it = (adj[x][y]).begin();
       it != (adj[x][y]).end(); it++)
    dfs(it->first, it->second, mask);
}
int rec(int x, int y) {
  int& ret = dp[x][y];
  if (~ret) return ret;
  ret = 0;
  for (__typeof((inv[x][y]).begin()) it = (inv[x][y]).begin();
       it != (inv[x][y]).end(); it++)
    umax(ret, rec(it->first, it->second));
  if (s[ret + 1] == arr[x][y]) ret++;
  return ret;
}
int main() {
  int n, m, qr;
  scanf("%d%d%d", &n, &m, &qr);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &arr[i][j]);
  for (int i = 0; i < 10; i++) scanf("%d%d", dx + i, dy + i);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int tox = dx[arr[i][j] - '0'] + i;
      int toy = dy[arr[i][j] - '0'] + j;
      if (tox < 1 or toy < 1 or tox > n or toy > m) tox = i, toy = j;
      adj[i][j].push_back(make_pair(tox, toy));
      inv[tox][toy].push_back(make_pair(i, j));
      deg[tox][toy]++;
    }
  queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!deg[i][j]) q.push(make_pair(i, j));
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    vis[x][y] = true;
    q.pop();
    for (__typeof((adj[x][y]).begin()) it = (adj[x][y]).begin();
         it != (adj[x][y]).end(); it++)
      if (!(--deg[it->first][it->second])) q.push(*it);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!vis[i][j] and !mark[i][j]) dfs(i, j, 0);
  while (qr--) {
    scanf("%s", s + 1);
    int sz = strlen(s + 1);
    DP[sz + 1] = 0;
    for (int i = sz; i >= 1; i--) DP[i] = DP[i + 1] | (1 << (s[i] - '0'));
    memset(dp, -1, sizeof dp);
    bool flag = false;
    for (int i = 1; i <= n; i++) {
      if (flag) break;
      for (int j = 1; j <= m; j++) {
        if (rec(i, j) == sz) {
          flag = true;
          break;
        }
        flag = true;
        for (int k = 0; k < 10; k++)
          if (DP[rec(i, j) + 1] >> k & 1 and !(MASK[i][j] >> k & 1)) {
            flag = false;
            break;
          }
        if (flag) break;
      }
    }
    if (flag)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
