#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
int n, m, q;
int visited[205][205];
int table[205][205];
int g1, g2;
vector<pair<int, int> > ab;
set<int> cans;
string s;
pair<int, int> nxt[205][205];
vector<pair<int, int> > prv[205][205];
int cycleNum[205][205];
vector<pair<int, int> > cycle[40005];
bool has[40005][10];
int idxCycle;
bool addTrigger;
void addCycle(int i, int j) {
  if (visited[i][j] == 2) return;
  if (visited[i][j] == 1) {
    addTrigger = true;
    cycle[idxCycle].push_back(make_pair(i, j));
    has[idxCycle][table[i][j]] = 1;
    cycleNum[i][j] = idxCycle;
    visited[i][j] = 2;
    return;
  }
  visited[i][j] = 1;
  addCycle(nxt[i][j].first, nxt[i][j].second);
  if (visited[i][j] == 1 && addTrigger) {
    cycle[idxCycle].push_back(make_pair(i, j));
    has[idxCycle][table[i][j]] = 1;
    cycleNum[i][j] = idxCycle;
  } else
    addTrigger = false;
  visited[i][j] = 2;
}
bool query(string& s, int pos, int x, int y) {
  if (pos >= 0 && table[x][y] == s[pos] - '0') pos--;
  if (pos == -1) return true;
  for (int i = 0; i < (int)prv[x][y].size(); i++) {
    if (query(s, pos, prv[x][y][i].first, prv[x][y][i].second)) return true;
  }
  return false;
}
void query(string& s, vector<int> idxs) {
  int n = s.length();
  memset(visited, 0, sizeof(visited));
  for (int i = 0; i < (int)idxCycle; i++) {
    int pos = -1;
    for (int j = 0; j < (int)10; j++) {
      if (!has[i][j] && idxs[j] != n) {
        pos = max(pos, idxs[j]);
      }
    }
    if (pos == -1) {
      cout << "YES" << endl;
      return;
    }
    for (int j = 0; j < (int)cycle[i].size(); j++) {
      if (query(s, pos, cycle[i][j].first, cycle[i][j].second)) {
        cout << "YES" << endl;
        return;
      }
    }
  }
  cout << "NO" << endl;
}
int main() {
  memset(has, 0, sizeof(has));
  memset(cycleNum, -1, sizeof(cycleNum));
  memset(visited, 0, sizeof(visited));
  ab.resize(10);
  cin >> n >> m >> q;
  for (int i = 0; i < (int)n; i++) {
    cin >> s;
    for (int j = 0; j < (int)m; j++) {
      table[i][j] = s[j] - '0';
    }
  }
  for (int i = 0; i < (int)10; i++) cin >> ab[i].first >> ab[i].second;
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)m; j++) {
      int ni = i + ab[table[i][j]].first, nj = j + ab[table[i][j]].second;
      if (ni >= 0 && ni < n && nj >= 0 && nj < m) {
        nxt[i][j] = make_pair(ni, nj);
      } else {
        nxt[i][j] = make_pair(i, j);
      }
    }
  }
  idxCycle = 0;
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)m; j++) {
      if (!visited[i][j]) {
        addCycle(i, j);
        if (cycle[idxCycle].size()) idxCycle++;
      }
    }
  }
  for (int i = 0; i < (int)n; i++) {
    for (int j = 0; j < (int)m; j++) {
      if (cycleNum[i][j] == -1) {
        prv[nxt[i][j].first][nxt[i][j].second].push_back(make_pair(i, j));
      }
    }
  }
  for (int i = 0; i < (int)q; i++) {
    cin >> s;
    string t = "";
    vector<int> idxs(10, s.length());
    for (int j = s.length() - 1; j >= 0; j--) idxs[(s[j] - '0')] = j, t += s[j];
    query(s, idxs);
  }
  return 0;
}
