#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void next_int(T &x) {
  x = 0;
  char c;
  bool neg = false;
  while (!isdigit(c = getchar()))
    if (c == '-') neg = true;
  do x = x * 10 + c - 48;
  while (isdigit(c = getchar()));
  if (neg) x = -x;
}
template <typename T>
inline void write_int(T x, char last = 0) {
  if (x < 0) putchar('-'), x = abs(x);
  char tmp[20];
  int cnt = 0;
  while (x >= 10) tmp[cnt++] = x % 10 + 48, x /= 10;
  tmp[cnt] = x + 48;
  for (int i = (cnt); i >= (0); --i) putchar(tmp[i]);
  if (last) putchar(last);
}
const int N = 205;
int n, m, q, cnt, mask[N * N], a[N * N], nxt[N * N], vis[N * N];
bool vis2[N * N];
pair<int, int> dir[10];
vector<int> c[N * N], rev[N * N], st;
char s[(int)1e6 + 5];
void dfs_cycle(int u) {
  st.push_back(u), vis[u] = 1;
  if (!vis[nxt[u]])
    dfs_cycle(nxt[u]);
  else if (vis[nxt[u]] == 1) {
    ++cnt;
    while (((int)st.size()) && st.back() != nxt[u]) {
      c[cnt].push_back(st.back()), mask[cnt] |= (1 << a[st.back()]);
      st.pop_back();
    }
    c[cnt].push_back(nxt[u]), mask[cnt] |= (1 << a[nxt[u]]), st.pop_back();
  }
  vis[u] = 2;
}
void getcycles() {
  for (int i = (1); i <= (n); ++i)
    if (!vis[i]) dfs_cycle(i);
}
void reverse_graph() {
  for (int i = (1); i <= (n); ++i) rev[nxt[i]].push_back(i);
}
bool dfs_work(int u, int pos, const int &len) {
  vis2[u] = true;
  if (pos > len) return true;
  for (int i = (0); i < (((int)rev[u].size())); ++i) {
    int v = rev[u][i], c = a[rev[u][i]];
    if (vis2[v]) continue;
    bool ok = false;
    if (c == s[pos] - '0')
      ok = dfs_work(v, pos + 1, len);
    else
      ok = dfs_work(v, pos, len);
    if (ok) return ok;
  }
  return false;
}
bool solve(int idcycle) {
  memset(vis2, false, sizeof(vis2));
  int len = strlen(s + 1), smask = 0;
  for (int i = (1); i <= (len); ++i) {
    smask |= (1 << (s[i] - '0'));
    if ((smask & mask[idcycle]) != smask)
      return dfs_work(c[idcycle][0], i, len);
  }
  return true;
}
int main() {
  next_int(n), next_int(m), next_int(q);
  for (int i = (1); i <= (n); ++i) {
    scanf("%s", s + 1);
    for (int j = (1); j <= (m); ++j) a[(i - 1) * m + j] = s[j] - '0';
  }
  for (int i = (0); i < (10); ++i)
    next_int(dir[i].first), next_int(dir[i].second);
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      int d = a[(i - 1) * m + j], ni = i + dir[d].first, nj = j + dir[d].second;
      if (!(ni > 0 && ni <= n && nj > 0 && nj <= m)) ni = i, nj = j;
      nxt[(i - 1) * m + j] = (ni - 1) * m + nj;
    }
  n *= m;
  getcycles();
  reverse_graph();
  while (q--) {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    reverse(s + 1, s + len + 1);
    bool ok = false;
    for (int i = (1); i <= (cnt); ++i)
      if (solve(i)) {
        puts("YES");
        ok = true;
        break;
      }
    if (!ok) puts("NO");
  }
  return 0;
}
