#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int N = 2e2 + 10, M = 1e6 + 10;
const int alp = 10;
vector<pair<int, int> > pos;
pair<int, int> s[M];
int n, m, q, a[N][N], f[N][N], h[N][N], len[N][N], dx[10], dy[10], deg[N][N],
    g[M];
string str;
bool check(int x, int y) { return x > 0 && x <= n && y > 0 && y <= m; }
void DFS(int sx, int sy) {
  int top = 1, spe = 0;
  int v = 0;
  s[1] = pair<int, int>(sx, sy);
  while (!spe) {
    int cx = s[top].first, cy = s[top].second;
    h[cx][cy] = top;
    int nx = cx + dx[a[cx][cy]], ny = cy + dy[a[cx][cy]];
    if (!check(nx, ny))
      spe = top;
    else {
      if (f[nx][ny]) {
        spe = top + 1;
        v = f[nx][ny];
        s[top + 1] = pair<int, int>(nx, ny);
        break;
      }
      if (!h[nx][ny])
        s[++top] = pair<int, int>(nx, ny);
      else
        spe = h[nx][ny];
    }
  }
  for (auto i = spe; i <= top; i++) v |= (1 << (a[s[i].first][s[i].second]));
  for (auto i = 1; i <= top; i++) f[s[i].first][s[i].second] = v;
  for (auto i = spe - 1; i >= 1; i--)
    len[s[i].first][s[i].second] = len[s[i + 1].first][s[i + 1].second] + 1;
}
void prepare() {
  cin >> n >> m >> q;
  for (auto i = 1; i <= n; i++) {
    cin >> str;
    for (auto j = 1; j <= m; j++) a[i][j] = str[j - 1] - '0';
  }
  for (auto i = 0; i < alp; i++) cin >> dx[i] >> dy[i];
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++) {
      int nx = i + dx[a[i][j]], ny = j + dy[a[i][j]];
      if (check(nx, ny)) deg[nx][ny]++;
    }
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++)
      if (!deg[i][j]) {
        DFS(i, j);
        pos.push_back(pair<int, int>(i, j));
      }
  for (auto i = 1; i <= n; i++)
    for (auto j = 1; j <= m; j++)
      if (!f[i][j]) {
        DFS(i, j);
        pos.push_back(pair<int, int>(i, j));
      }
}
string solve() {
  int n1 = str.length();
  g[n1] = 0;
  for (auto i = n1 - 1; i >= 0; i--) g[i] = g[i + 1] | (1 << (str[i] - '0'));
  for (auto x : pos) {
    int cur = 0;
    pair<int, int> cx = x;
    while (cur < n1 && len[cx.first][cx.second]) {
      int v = a[cx.first][cx.second];
      if (str[cur] - '0' == v) cur++;
      int nx = cx.first + dx[v], ny = cx.second + dy[v];
      cx = pair<int, int>(nx, ny);
    }
    if ((g[cur] & f[cx.first][cx.second]) == g[cur]) return "YES";
  }
  return "NO";
}
int main() {
  prepare();
  while (q--) {
    cin >> str;
    cout << solve() << '\n';
  }
}
