#include <bits/stdc++.h>
using namespace std;
const long long linf = 1e18 + 5;
const int mod = (int)1e9 + 7;
const int logN = 18;
const int inf = 1e9;
const int N = 210;
int q, dx[11], dy[11], in[N][N], dp[N][N], n, m, x, y, mask[N][N], h[N][N],
    h2[N][N], h3[N][N], t, cc[12];
vector<pair<int, int> > v[N][N], g[N][N];
char str[1000005], arr[N][N];
int mk[1000007];
int dfs(int x, int y, int S) {
  if (h2[x][y]) {
    int mask = 0;
    for (int i = 0; i <= 9; i++)
      if (cc[i] > 0) mask |= (1 << i);
    return mask;
  }
  int mask = 0;
  h2[x][y] = 1;
  cc[arr[x][y] - '0']++;
  for (__typeof(v[x][y].begin()) it = v[x][y].begin(); it != v[x][y].end();
       it++)
    if (!h[it->first][it->second]) return dfs(it->first, it->second, S);
  assert(0);
}
void dfs2(int x, int y, int S) {
  if (h3[x][y]) return;
  h3[x][y] = 1;
  mask[x][y] = S;
  for (__typeof(v[x][y].begin()) it = v[x][y].begin(); it != v[x][y].end();
       it++)
    dfs2(it->first, it->second, S);
}
int f(int x, int y) {
  int &r = dp[x][y];
  if (r != -1) return r;
  r = 0;
  for (__typeof(v[x][y].begin()) it = v[x][y].begin(); it != v[x][y].end();
       it++)
    if (h[it->first][it->second]) r = max(r, f(it->first, it->second));
  if (str[r + 1] == arr[x][y]) r++;
  return r;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &arr[i][j]);
  for (int i = 0; i <= 9; i++) scanf("%d %d", &dx[i], &dy[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      int x = i + dx[arr[i][j] - '0'];
      int y = j + dy[arr[i][j] - '0'];
      if (x < 1 || x > n || y < 1 || y > m) {
        x = i;
        y = j;
      }
      v[x][y].push_back(make_pair(i, j));
      g[i][j].push_back(make_pair(x, y));
      in[x][y]++;
    }
  queue<pair<int, int> > q;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!in[i][j]) q.push(make_pair(i, j));
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    h[x][y] = 1;
    q.pop();
    for (__typeof(g[x][y].begin()) it = g[x][y].begin(); it != g[x][y].end();
         it++)
      if (!--in[it->first][it->second])
        q.push(make_pair(it->first, it->second));
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (!h[i][j] && !h2[i][j]) {
        memset(cc, 0, sizeof cc);
        int mm = dfs(i, j, 1);
        dfs2(i, j, mm);
      }
  for (int tt = 1; tt <= ::q; tt++) {
    scanf("%s", str + 1);
    int nn = strlen(str + 1);
    memset(cc, 0, sizeof cc);
    mk[nn + 1] = 0;
    for (int i = nn; i >= 1; i--) {
      cc[str[i] - '0']++;
      mk[i] = 0;
      for (int j = 0; j <= 9; j++)
        if (cc[j]) mk[i] |= (1 << j);
    }
    int ff = 0;
    memset(dp, -1, sizeof dp);
    for (int xx = 1; xx <= n; xx++) {
      if (ff) break;
      for (int yy = 1; yy <= m; yy++) {
        if ((mk[f(xx, yy) + 1] & mask[xx][yy]) == mk[f(xx, yy) + 1]) {
          cout << "YES\n";
          ff = 1;
          break;
        }
      }
    }
    if (!ff) cout << "NO\n";
  }
  return 0;
}
