#include <bits/stdc++.h>
using namespace std;
vector<vector<long long> > matmul(vector<vector<long long> > &a,
                                  vector<vector<long long> > &b) {
  int i, j, k, n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      long long temp = 0;
      for (k = 0; k < n; k++)
        temp = (temp + a[i][k] * b[k][j]) % (1000000007LL);
      ans[i][j] = temp;
    }
  return ans;
}
vector<vector<long long> > matpwr(vector<vector<long long> > &a, long long p) {
  int n = a.size();
  vector<vector<long long> > ans(n, vector<long long>(n));
  for (int i = 0; i < n; i++) ans[i][i] = 1;
  while (p) {
    if (p & 1) ans = matmul(ans, a);
    a = matmul(a, a);
    p >>= 1;
  }
  return ans;
}
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long invMod(long long n, long long mod = (1000000007LL)) {
  return pwr(n, mod - 2, mod);
}
int r, c, arr[202][202], jump[200 * 200 + 4][12], dx[12], dy[12];
bool done[202][202];
vector<int> startPos;
bool valid(int x, int y) { return (x >= 0 && x < r && y >= 0 && y < c); }
inline int id(int x, int y) { return x * c + y; }
void dfs(int x, int y) {
  done[x][y] = true;
  int idx = id(x, y), dig = arr[x][y];
  jump[idx][dig] = idx;
  int xx = x + dx[dig], yy = y + dy[dig];
  if (valid(xx, yy)) {
    if (!done[xx][yy]) dfs(xx, yy);
    for (int k = 0; k < 10; k++)
      if (k != dig) jump[idx][k] = jump[id(xx, yy)][k];
  }
}
bool possible(string str) {
  int len = str.length();
  for (int s = 0; s < (int)startPos.size(); s++) {
    int pos = startPos[s], cnt = 0;
    for (int i = 0; i < len; i++, cnt++) {
      int dig = str[i] - '0';
      int x = pos / c, y = pos % c;
      if (dig == arr[x][y]) {
        if (valid(x + dx[dig], y + dy[dig])) {
          x += dx[dig];
          y += dy[dig];
          pos = id(x, y);
        }
        continue;
      }
      if (jump[pos][dig] == -1) break;
      pos = jump[pos][dig];
    }
    if (cnt == len) return true;
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  int q;
  cin >> r >> c >> q;
  for (int i = 0; i < r; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < c; j++) arr[i][j] = s[j] - '0';
  }
  for (int i = 0; i < 10; i++) cin >> dx[i] >> dy[i];
  memset(jump, -1, sizeof(jump));
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++)
      if (!done[i][j]) {
        dfs(i, j);
        startPos.push_back(id(i, j));
      }
  while (q--) {
    string str;
    cin >> str;
    if (possible(str))
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
