#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 333;
const long long linf = 1e18 + 333;
const int N = 205 * 205;
const int M = 1e6 + 5;
int n, m, q;
char a[N], str[N], s[M];
int mask[M];
vector<int> v[N];
int gox[10], goy[10], goadd[10], go[N];
bool h[N], isCycle[N];
int cycCnt;
int cycle[N], maskOf[N], dp[N];
vector<int> curCycle;
int find(int x) {
  curCycle.push_back(x);
  h[x] = 1;
  if (h[go[x]]) return go[x];
  return find(go[x]);
}
void dfs(int x) {
  cycle[x] = cycCnt;
  h[x] = 1;
  for (__typeof((v[x]).begin()) it = (v[x]).begin(); it != (v[x]).end(); it++) {
    int u = *it;
    if (!h[u]) dfs(u);
  }
}
int f(int x) {
  int &r = dp[x];
  if (r != -1) return r;
  r = 0;
  for (__typeof((v[x]).begin()) it = (v[x]).begin(); it != (v[x]).end(); it++) {
    int u = *it;
    r = max(r, f(u));
  }
  return r += (s[r] == a[x]);
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  int sz = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    for (int i = 0; i < m; i++) a[++sz] = str[i];
  }
  for (int i = 0; i < 10; i++) {
    scanf("%d %d", gox + i, goy + i);
  }
  for (int i = 1; i <= n * m; i++) a[i] -= '0';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int x = i + gox[a[(i - 1) * m + j]];
      int y = j + goy[a[(i - 1) * m + j]];
      if (x >= 1 and x <= n and y >= 1 and y <= m)
        go[(i - 1) * m + j] = (x - 1) * m + y;
      else
        go[(i - 1) * m + j] = (i - 1) * m + j;
    }
  }
  n *= m;
  for (int i = 1; i <= n; i++) {
    v[go[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) {
    if (!h[i]) {
      curCycle.clear();
      int x = find(i);
      for (__typeof((curCycle).begin()) it = (curCycle).begin();
           it != (curCycle).end(); it++)
        h[*it] = 0;
      reverse(curCycle.begin(), curCycle.end());
      while (curCycle.size() and curCycle.back() != x) curCycle.pop_back();
      assert(curCycle.size());
      cycCnt++;
      for (__typeof((curCycle).begin()) it = (curCycle).begin();
           it != (curCycle).end(); it++) {
        isCycle[*it] = 1;
        h[*it] = 1;
      }
      for (__typeof((curCycle).begin()) it = (curCycle).begin();
           it != (curCycle).end(); it++) {
        dfs(*it);
      }
      int mask = 0;
      for (__typeof((curCycle).begin()) it = (curCycle).begin();
           it != (curCycle).end(); it++) {
        mask |= 1 << a[*it];
      }
      maskOf[cycCnt] = mask;
    }
  }
  vector<int> qu;
  for (int i = 1; i <= q; i++) {
    scanf("%s", s);
    int m = strlen(s);
    for (int i = 0; i < m; i++) s[i] -= '0';
    mask[m] = 0;
    for (int i = m - 1; i >= 0; i--) mask[i] = mask[i + 1] | (1 << s[i]);
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (!isCycle[i]) {
        int x = f(i);
        if (mask[x] == (mask[x] & maskOf[cycle[i]])) {
          ans = 1;
          break;
        }
      } else {
        if (mask[0] == (mask[0] & maskOf[cycle[i]])) {
          ans = 1;
          break;
        }
      }
    }
    if (ans)
      puts("YES");
    else
      puts("NO");
  }
  return 0;
}
