#include <bits/stdc++.h>
using namespace std;
const int N = 205;
string s, F;
char a[N][N];
int n, m, q, mark[N][N], dx[10], dy[10], top, d[N][N], dig[N * N][10], num,
    in[N][N];
vector<pair<int, int> > c[N][N], cyc[N * N], out_cyc;
pair<int, int> STACK[N * N];
void INP() {
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  for (int i = 0; i <= 9; i++) cin >> dx[i] >> dy[i];
}
void dfs_cyc(int u, int v, int ok) {
  if (d[u][v] == ok) {
    num++;
    while (top) {
      pair<int, int> p = STACK[top--];
      dig[num][a[p.first][p.second] - '0'] = 1;
      mark[p.first][p.second] = 1;
      cyc[num].push_back(p);
    }
    return;
  }
  if (d[u][v]) return;
  STACK[++top] = pair<int, int>(u, v);
  d[u][v] = ok;
  for (int i = 0; i < c[u][v].size(); i++) {
    int first = c[u][v][i].first;
    int second = c[u][v][i].second;
    dfs_cyc(first, second, ok);
  }
  if (top) top--;
}
void make_graph() {
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int digit = a[i][j] - '0';
      int first = i + dx[digit];
      int second = j + dy[digit];
      if (1 > first || first > n || 1 > second || second > m) continue;
      c[first][second].push_back(pair<int, int>(i, j));
      in[i][j] = 1;
    }
  int tmp = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!d[i][j]) dfs_cyc(i, j, ++tmp);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!mark[i][j]) out_cyc.push_back(pair<int, int>(i, j));
}
int dfscheck(int u, int v, int pos) {
  if (a[u][v] == F[pos])
    while (pos < F.size() && a[u][v] == F[pos]) pos++;
  if (pos == F.size()) return 1;
  for (int i = 0; i < c[u][v].size(); i++) {
    int first = c[u][v][i].first;
    int second = c[u][v][i].second;
    if (dfscheck(first, second, pos)) return 1;
  }
  return 0;
}
int Check() {
  for (int i = 1; i <= num; i++) {
    int j = 0;
    int sz = s.size();
    while (j < sz && dig[i][s[j] - '0']) j++;
    if (j == sz) return 1;
    F = "";
    for (; j < sz; j++) F = F + s[j];
    for (j = 0; j < cyc[i].size(); j++) {
      pair<int, int> u = cyc[i][j];
      for (int k = 0; k < c[u.first][u.second].size(); k++) {
        pair<int, int> v = c[u.first][u.second][k];
        if (!mark[v.first][v.second] && dfscheck(v.first, v.second, 0))
          return 1;
      }
    }
  }
  F = s;
  for (int i = 0; i < out_cyc.size(); i++) {
    int first = out_cyc[i].first;
    int second = out_cyc[i].second;
    if (!in[first][second] && dfscheck(first, second, 0)) return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  INP();
  make_graph();
  for (int i = 1; i <= q; i++) {
    cin >> s;
    reverse(s.begin(), s.end());
    cout << (Check() ? "YES\n" : "NO\n");
  }
  return 0;
}
