#include <bits/stdc++.h>
using namespace std;
const int N = 505, M = 1e6 + 7;
int n, m, Q, St, flag, ln;
int mp[N][N], vis[N][N], flg[N][N], huan[M], hh[M], a[10], b[10];
char s[N][N], ss[M];
pair<int, int> st[N * N];
void dfs(int x, int y, int t) {
  if (vis[x][y]) return;
  st[++St] = make_pair(x, y);
  vis[x][y] = t;
  int xx = x + a[mp[x][y]], yy = y + b[mp[x][y]];
  if (xx > n || xx < 1 || yy > m || yy < 1) xx = x, yy = y;
  if (vis[xx][yy] == t) {
    ++*huan;
    for (int i = St;; i--) {
      int sx = st[i].first, sy = st[i].second;
      flg[sx][sy] = *huan;
      huan[*huan] |= 1 << mp[sx][sy];
      if (st[i] == make_pair(xx, yy)) break;
    }
  } else
    dfs(xx, yy, t);
  St--;
}
void dfs1(int x, int y, int stp) {
  if (stp > ln) {
    flag = 1;
    return;
  }
  if (flg[x][y]) {
    if ((hh[stp] & huan[flg[x][y]]) == hh[stp]) flag = 1;
    return;
  }
  vis[x][y] = 1;
  int xx = x + a[mp[x][y]], yy = y + b[mp[x][y]];
  if (s[x][y] == ss[stp])
    dfs1(xx, yy, stp + 1);
  else
    dfs1(xx, yy, stp);
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) mp[i][j] = s[i][j] - '0';
  for (int i = 0; i < 10; i++) scanf("%d%d", &a[i], &b[i]);
  for (int i = 1, k = 0; i <= n; i++)
    for (int j = 1; j <= m; j++) dfs(i, j, ++k);
  while (Q--) {
    scanf("%s", ss + 1);
    ln = strlen(ss + 1);
    hh[ln + 1] = 0;
    for (int i = ln; i; i--) {
      hh[i] = hh[i + 1];
      hh[i] |= 1 << ss[i] - '0';
    }
    memset(vis, 0, sizeof vis);
    flag = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (!vis[i][j]) {
          dfs1(i, j, 1);
          if (flag) break;
        }
    puts(flag ? "YES" : "NO");
  }
}
