#include <bits/stdc++.h>
using namespace std;
const int MAX = 300;
int n, m;
struct cell {
  int mask = 0;
  bool operator[](int i) { return mask & (1 << i); }
};
cell arr[MAX][MAX];
vector<pair<int, int> > adj[MAX][MAX];
int inDegree[MAX][MAX], _Time, visTime[MAX][MAX], lowTime[MAX][MAX],
    compIdx[MAX][MAX];
bool inStack[MAX][MAX];
void SCC(int x, int y, stack<pair<int, int> >& s) {
  visTime[x][y] = lowTime[x][y] = ++_Time;
  s.push({x, y});
  inStack[x][y] = 1;
  for (auto v : adj[x][y])
    if (!visTime[v.first][v.second]) {
      SCC(v.first, v.second, s);
      lowTime[x][y] = min(lowTime[x][y], lowTime[v.first][v.second]);
    } else if (inStack[x][y])
      lowTime[x][y] = min(lowTime[x][y], lowTime[v.first][v.second]);
  if (visTime[x][y] == lowTime[x][y]) {
    vector<pair<int, int> > temp;
    int cnt = 0;
    int v, u;
    compIdx[x][y] = lowTime[x][y];
    do {
      cnt++;
      v = s.top().first, u = s.top().second;
      s.pop();
      inStack[v][u] = 0;
      compIdx[v][u] = compIdx[x][y];
      arr[x][y].mask |= arr[v][u].mask;
      vector<pair<int, int> >& to = adj[v][u];
      for (int i = 0; i < int(to.size()); i++)
        if (!inStack[to[i].first][to[i].second] &&
            compIdx[to[i].first][to[i].second] != compIdx[x][y])
          temp.push_back(to[i]);
    } while (v != x || u != y);
    if (cnt > 1) inDegree[x][y] = 0;
    adj[x][y] = temp;
  }
}
void getDAG() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (!visTime[i][j]) {
        stack<pair<int, int> > s;
        SCC(i, j, s);
      }
}
bool getPath(int x, int y, int idx, string& str) {
  if (idx + arr[x][y][str[idx] - '0'] == int(str.size())) return 1;
  vector<pair<int, int> >& to = adj[x][y];
  for (int i = 0; i < int(to.size()); i++)
    if (getPath(to[i].first, to[i].second, idx + arr[x][y][str[idx] - '0'],
                str))
      return 1;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char ch;
      cin >> ch;
      arr[i][j].mask |= 1 << (ch - '0');
    }
  for (int k = 0; k < 10; k++) {
    int x, y;
    cin >> x >> y;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (arr[i][j][k] && i + x >= 0 && i + x < n && j + y >= 0 && j + y < m)
          adj[i + x][j + y].push_back({i, j}), inDegree[i][j]++;
  }
  getDAG();
  while (q--) {
    string str;
    cin >> str;
    reverse(str.begin(), str.end());
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        if (!inDegree[i][j]) {
          int idx = 0;
          while (arr[i][j][str[idx] - '0']) idx++;
          if (getPath(i, j, idx, str)) {
            cout << "YES\n";
            goto ESHTA;
          }
        }
    cout << "NO\n";
  ESHTA:;
  }
  return 0;
}
