#include <bits/stdc++.h>
using namespace std;
const int MAXN = 240;
int n, m, q;
int grid[MAXN][MAXN], vis[MAXN][MAXN];
pair<int, int> d[10], iniCycle[MAXN * MAXN];
int nxtId, sons[MAXN][MAXN];
void dfs(int i, int j, int iter) {
  vis[i][j] = iter;
  int ni = i + d[grid[i][j]].first;
  int nj = j + d[grid[i][j]].second;
  if (ni < 0 || nj < 0 || ni >= n || nj >= m) {
    ni = i;
    nj = j;
  }
  if (vis[ni][nj] == 0) {
    ;
    ;
    dfs(ni, nj, iter);
  } else if (vis[ni][nj] != iter) {
    ;
    ;
  } else {
    ;
    ;
    ;
    ;
    iniCycle[nxtId] = make_pair(i, j);
    nxtId++;
  }
  sons[ni][nj]++;
}
vector<pair<int, int> > inivertex;
set<int> setCycle[MAXN * MAXN];
int cycleId[MAXN][MAXN];
void getCycle(int id) {
  int i = iniCycle[id].first;
  int j = iniCycle[id].second;
  int cnt = 0;
  while ((make_pair(i, j) != iniCycle[id]) || cnt == 0) {
    cnt++;
    setCycle[id].insert(grid[i][j]);
    cycleId[i][j] = id;
    int ni = i + d[grid[i][j]].first;
    int nj = j + d[grid[i][j]].second;
    if (ni < 0 || nj < 0 || ni >= n || nj >= m) {
      ni = i;
      nj = j;
    }
    i = ni;
    j = nj;
  }
}
string text;
bool tryCycle(int id, int ini = 0) {
  for (int i = ini; i < text.size(); i++) {
    int dd = text[i] - '0';
    if (setCycle[id].count(dd) == 0) return false;
  }
  return true;
}
bool trypath(pair<int, int> p) {
  int i = p.first;
  int j = p.second;
  int k = 0;
  while (cycleId[i][j] == -1 && k < text.size()) {
    int dd = text[k] - '0';
    if (dd == grid[i][j]) {
      k++;
    }
    int ni = i + d[grid[i][j]].first;
    int nj = j + d[grid[i][j]].second;
    if (ni < 0 || nj < 0 || ni >= n || nj >= m) {
      ni = i;
      nj = j;
    }
    i = ni;
    j = nj;
  }
  if (k == text.size())
    return true;
  else if (cycleId[i][j] != -1)
    return tryCycle(cycleId[i][j], k);
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      sons[i][j] = vis[i][j] = 0;
      cycleId[i][j] = -1;
    }
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      grid[i][j] = s[j] - '0';
    }
  }
  for (int i = 0; i < 10; i++) {
    cin >> d[i].first >> d[i].second;
  }
  nxtId = 0;
  int iter = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (vis[i][j] != 0) continue;
      dfs(i, j, iter);
      iter++;
    }
  };
  ;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (sons[i][j] == 0) inivertex.push_back(make_pair(i, j));
  for (int i = 0; i < nxtId; i++) {
    getCycle(i);
  }
  for (int qq = 0; qq < q; qq++) {
    cin >> text;
    bool flg = false;
    for (int j = 0; j < inivertex.size(); j++) {
      bool val = trypath(inivertex[j]);
      flg |= val;
      if (flg) break;
    }
    if (flg) {
      cout << "YES" << endl;
      continue;
    }
    for (int j = 0; j < nxtId; j++) {
      bool val = tryCycle(j);
      flg |= val;
      if (flg) break;
    }
    if (flg)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
