#include <bits/stdc++.h>
using namespace std;
int n, m, q, a[205], b[205], comp[205][205], last[10];
pair<int, int> G[205][205];
vector<pair<int, int> > G_rev[205][205];
char A[205][205], str[1000005];
bool cycle[205][205], cycle_set[205 * 205 + 1][10], vis[205 * 205 + 1];
bool valid(pair<int, int> p) {
  return p.first >= 0 && p.first < n && p.second >= 0 && p.second < m;
}
int cx, cy;
bool dfs1(int x, int y, int r) {
  int i = G[x][y].first, j = G[x][y].second, ret = false;
  comp[x][y] = r;
  if (!valid(G[x][y])) return false;
  if (!comp[i][j])
    ret = dfs1(i, j, r);
  else if (comp[i][j] == comp[x][y]) {
    cx = i;
    cy = j;
    ret = true;
  }
  if (ret) cycle[x][y] = true;
  return ret && !(x == cx && y == cy);
}
bool dfs2(int x, int y, char *str, int l) {
  bool ret = false;
  if (!l) return true;
  if (!G_rev[x][y].size() && l == 1) return str[l - 1] == A[x][y];
  for (int i = (0); i < (G_rev[x][y].size()); i++) {
    int u = G_rev[x][y][i].first, v = G_rev[x][y][i].second;
    if (!cycle[u][v]) {
      if (str[l - 1] == A[x][y])
        ret |= dfs2(u, v, str, l - 1);
      else
        ret |= dfs2(u, v, str, l);
      if (ret) return true;
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = (0); i < (n); i++) scanf(" %s", A[i]);
  for (int i = (0); i < (10); i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      int t = A[i][j] - '0';
      pair<int, int> np = make_pair(i + a[t], j + b[t]);
      G[i][j] = np;
      if (valid(np)) G_rev[np.first][np.second].push_back(make_pair(i, j));
    }
  int r = 1;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++)
      if (!comp[i][j]) {
        cx = cy = -1;
        dfs1(i, j, r++);
      }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++)
      if (cycle[i][j]) cycle_set[comp[i][j]][A[i][j] - '0'] = true;
  for (int x = (0); x < (q); x++) {
    bool ans = false;
    scanf(" %s", str);
    int lstr = strlen(str);
    for (int i = (0); i < (10); i++) last[i] = -1;
    for (int i = lstr - 1; i >= 0; i--)
      last[str[i] - '0'] = max(last[str[i] - '0'], i);
    int l = lstr;
    while (l > 1 && str[l - 1] == str[l - 2]) l--;
    for (int i = (0); i < (n); i++)
      for (int j = (0); j < (m); j++)
        if (!valid(G[i][j]))
          if (ans = dfs2(i, j, str, l)) {
            i = n + 1;
            j = m + 1;
          }
    if (!ans) {
      for (int i = (1); i < (r + 1); i++) vis[i] = false;
      for (int i = (0); i < (n); i++)
        for (int j = (0); j < (m); j++)
          if (!vis[comp[i][j]] && cycle[i][j]) {
            vis[comp[i][j]] = true;
            l = -1;
            for (int k = (0); k < (10); k++)
              if (!cycle_set[comp[i][j]][k]) l = max(l, last[k]);
            l++;
            int x = i, y = j;
            do {
              int t = x;
              x = G[x][y].first;
              y = G[t][y].second;
              if (ans = dfs2(x, y, str, l)) {
                i = n + 1;
                j = m + 1;
                x = i;
                y = j;
              }
            } while (x != i || y != j);
          }
    }
    printf("%s\n", ans ? "YES" : "NO");
  }
  return 0;
}
