#include <bits/stdc++.h>
using namespace std;
int n, m, dx[20], dy[20], mask[205][205], poz[100], maxx;
char a[205][205], sir[1000005];
bool viz[205][205], seen[205][205];
bool ok;
struct el {
  int x, y;
};
vector<el> T[205][205];
el st[205 * 205];
int top;
inline void Vecin(int x, int y, int &xx, int &yy) {
  xx = x + dx[a[x][y] - '0'];
  yy = y + dy[a[x][y] - '0'];
  if (xx < 1 || xx > n || yy < 1 || yy > m) {
    xx = x;
    yy = y;
  }
}
inline void Cycle(int xx, int yy) {
  int nr = (1 << a[xx][yy] - '0'), x, y;
  Vecin(xx, yy, x, y);
  while (x != xx || y != yy) {
    nr |= (1 << (a[x][y] - '0'));
    Vecin(x, y, x, y);
  }
  mask[xx][yy] = nr;
  Vecin(xx, yy, x, y);
  while (x != xx || y != yy) {
    mask[x][y] = nr;
    Vecin(x, y, x, y);
  }
}
inline void Dfs(int x, int y) {
  el w;
  w.x = x;
  w.y = y;
  st[++top] = w;
  seen[x][y] = true;
  viz[x][y] = true;
  int xx, yy;
  Vecin(x, y, xx, yy);
  if (seen[xx][yy]) {
    Cycle(xx, yy);
    return;
  }
  if (!viz[xx][yy]) {
    seen[xx][yy] = true;
    Dfs(xx, yy);
  }
}
inline void Dfs1(int x, int y, int p) {
  if (ok) return;
  if (a[x][y] == sir[p]) --p;
  if (!p) {
    ok = 1;
    return;
  }
  for (auto it : T[x][y]) Dfs1(it.x, it.y, p);
}
int main() {
  int i, j, k, len, q;
  cin.sync_with_stdio(0);
  cin >> n >> m >> q;
  for (i = 1; i <= n; ++i) cin >> (a[i] + 1);
  for (i = 0; i < 10; ++i) cin >> dx[i] >> dy[i];
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j)
      if (!viz[i][j]) {
        top = 0;
        Dfs(i, j);
        for (k = 1; k <= top; ++k) seen[st[k].x][st[k].y] = false;
      }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= m; ++j) {
      el w, w1;
      Vecin(i, j, w.x, w.y);
      if (w.x != i || w.y != j && !mask[i][j]) {
        w1.x = i;
        w1.y = j;
        T[w.x][w.y].push_back(w1);
      }
    }
  while (q--) {
    cin >> (sir + 1);
    len = strlen(sir + 1);
    ok = false;
    for (i = 0; i < 10; ++i) poz[i] = 0;
    for (i = 1; i <= len; ++i) poz[sir[i] - '0'] = i;
    for (i = 1; i <= n && !ok; ++i)
      for (j = 1; j <= m && !ok; ++j)
        if (mask[i][j]) {
          for (k = maxx = 0; k < 10; ++k)
            if (!(mask[i][j] & (1 << k))) maxx = max(maxx, poz[k]);
          if (!maxx) ok = true;
          Dfs1(i, j, maxx);
        }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
