#include <bits/stdc++.h>
using namespace std;
const int N = 210;
const int M = 11;
const long long INF = 1LL << 58;
const double EPS = 1e-8;
int n, m, q, num[N][N], dx[M], dy[M];
int vis[N][N], in_cycle[N][N];
vector<int> cycle;
vector<vector<pair<int, int> > > start;
vector<pair<int, int> > tree[N][N];
bool hasNext(int xx, int yy) {
  return !(xx < 0 || yy < 0 || xx >= n || yy >= m);
}
pair<int, int> getNext(int x, int y) {
  int d = num[x][y];
  int xx = x + dx[d], yy = y + dy[d];
  if (hasNext(xx, yy)) {
    return make_pair(xx, yy);
  } else {
    return make_pair(x, y);
  }
}
int dfs(int x, int y) {
  if (!vis[x][y]) {
    vis[x][y] = 1;
    pair<int, int> nxt = getNext(x, y);
    int cycle_id = dfs(nxt.first, nxt.second);
    if (vis[x][y] == 2) {
      return cycle_id;
    }
    vis[x][y] = 3;
    pair<int, int> cur = make_pair(x, y);
    if (vis[nxt.first][nxt.second] == 2) {
      start[cycle_id - 1].push_back(cur);
    } else {
      tree[nxt.first][nxt.second].push_back(cur);
    }
    return cycle_id;
  }
  if (vis[x][y] == 2) {
    return in_cycle[x][y];
  }
  if (vis[x][y] == 3) {
    return 0;
  }
  if (vis[x][y] == 1) {
    vector<pair<int, int> > v;
    pair<int, int> cur = make_pair(x, y);
    int cycle_id = cycle.size() + 1;
    int mask = 0;
    while (true) {
      cur = getNext(cur.first, cur.second);
      vis[cur.first][cur.second] = 2;
      mask |= (1 << num[cur.first][cur.second]);
      in_cycle[cur.first][cur.second] = cycle_id;
      if (cur == make_pair(x, y)) {
        break;
      }
    }
    cycle.push_back(mask);
    start.push_back(vector<pair<int, int> >());
    return cycle_id;
  }
  assert(false);
}
void build_cycle() {
  cycle.clear();
  start.clear();
  memset(vis, 0, sizeof(vis));
  memset(in_cycle, 0, sizeof(in_cycle));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vis[i][j]) {
        continue;
      }
      dfs(i, j);
    }
  }
}
void init() {
  memset(num, 0, sizeof(num));
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      num[i][j] = s[j] - '0';
      tree[i][j].clear();
    }
  }
  for (int i = 0; i < 10; i++) {
    cin >> dx[i] >> dy[i];
  }
  build_cycle();
  return;
  for (int i = 0; i < cycle.size(); i++) {
    printf("%d ", cycle[i]);
  }
  printf("\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%d ", in_cycle[i][j]);
    }
    printf("\n");
  }
  for (int i = 0; i < start.size(); i++) {
    for (int j = 0; j < start[i].size(); j++) {
      printf("Cycle %d, %d %d\n", i, start[i][j].first, start[i][j].second);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < tree[i][j].size(); k++) {
        printf("Next of %d %d is %d %d\n", i, j, tree[i][j][k].first,
               tree[i][j][k].second);
      }
    }
  }
}
vector<int> vm, vsn;
int getPla(int mask) {
  int lt = 0, rt = vm.size() - 1;
  while (lt < rt) {
    int md = (lt + rt) >> 1;
    if ((vm[md] & mask) == vm[md]) {
      lt = md + 1;
    } else {
      rt = md;
    }
  }
  return lt - 1;
}
bool checkAns(pair<int, int> cur, int p) {
  if (p >= vm.size() - 1) {
    return true;
  }
  int cur_num = num[cur.first][cur.second];
  if (cur_num == vsn[p]) {
    p++;
  }
  if (p >= vm.size() - 1) {
    return true;
  }
  for (int i = 0; i < tree[cur.first][cur.second].size(); i++) {
    if (checkAns(tree[cur.first][cur.second][i], p)) {
      return true;
    }
  }
  return false;
}
bool solve(string s) {
  int len = s.size();
  int mask = 0;
  vm = vector<int>(len + 1);
  vsn = vector<int>(len);
  for (int i = len - 1; i >= 0; i--) {
    mask |= (1 << (s[i] - '0'));
    vsn[len - i - 1] = s[i] - '0';
    vm[len - i - 1] = mask;
  }
  vm[len] = 1111111111;
  for (int i = 0; i < cycle.size(); i++) {
    int pla = getPla(cycle[i]);
    if (pla >= len - 1) {
      return true;
    }
    for (int j = 0; j < start[i].size(); j++) {
      pair<int, int> cur = start[i][j];
      if (checkAns(cur, pla + 1)) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  while (cin >> n >> m >> q) {
    init();
    while (q--) {
      string s;
      cin >> s;
      printf("%s\n", solve(s) ? "YES" : "NO");
    }
  }
}
