#include <bits/stdc++.h>
using namespace std;
int n, m;
int q, f[205 * 205][10];
int visited[205][205];
int dx[10];
int dy[10];
char a[205][205], s[1000006];
vector<int> b;
int id(int x, int y) { return x * m + y; }
bool check(int x, int y) {
  if ((x >= 0) && (x < n) && (y >= 0) && (y < m)) return true;
  return false;
}
void dfs(int x, int y) {
  visited[x][y] = 1;
  int t = a[x][y] - 48, u = id(x, y);
  int xx = x + dx[t], yy = y + dy[t];
  if (check(xx, yy)) {
    int v = f[u][t] = id(xx, yy);
    if (!visited[xx][yy]) dfs(xx, yy);
    for (int i = 0; i < 10; i++)
      if (i != t) f[u][i] = f[v][i];
  } else
    f[u][t] = u;
}
bool query(string s) {
  int nn = s.length();
  for (int i = 0; i < b.size(); i++) {
    int x = b[i];
    for (int p = 0; p < nn; p++) {
      x = f[x][s[p] - '0'];
      if (x < 0) break;
    }
    if (x >= 0) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 10; i++) cin >> dx[i] >> dy[i];
  memset(f, 0xFF, sizeof(f));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (visited[i][j]) continue;
      b.push_back(id(i, j));
      dfs(i, j);
    }
  while (q--) {
    cin >> s;
    cout << (query(s) ? "YES" : "NO") << endl;
  }
  return 0;
}
