#include <bits/stdc++.h>
using namespace std;
template <typename T>
class heap : public priority_queue<T, vector<T>, greater<T> > {};
pair<int, int> operator+(const pair<int, int> x, const pair<int, int> y) {
  return {x.first + y.first, x.second + y.second};
}
int mapa[210][210];
int visited[210][210];
int deg[210][210];
int deg2[210][210];
int len[210][210];
int n, m;
pair<int, int> mov[10];
char s[1000047];
int suf[1000047];
void dfs(pair<int, int> x) {
  if (visited[x.first][x.second] != -1) return;
  visited[x.first][x.second] = -2;
  auto next = x + mov[mapa[x.first][x.second]];
  if (next.first < 0 || next.first >= n || next.second < 0 || next.second >= m)
    return;
  if (visited[next.first][next.second] == -2) {
    int seen = 1 << mapa[x.first][x.second];
    auto it = next;
    while (it != x) {
      seen |= 1 << mapa[it.first][it.second];
      it = it + mov[mapa[it.first][it.second]];
    }
    visited[x.first][x.second] = seen;
    it = next;
    while (it != x) {
      visited[it.first][it.second] = seen;
      it = it + mov[mapa[it.first][it.second]];
    }
  } else {
    ++deg[next.first][next.second];
    dfs(next);
  }
}
void dfs2(pair<int, int> x) {
  if (visited[x.first][x.second] != -2) return;
  visited[x.first][x.second] = 0;
  auto next = x + mov[mapa[x.first][x.second]];
  if (next.first < 0 || next.first >= n || next.second < 0 || next.second >= m)
    return;
  dfs2(next);
}
void print_arr(int a[210][210]) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) printf("%d ", a[i][j]);
    printf("\n");
  }
  printf("\n");
}
int main(void) {
  int q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i) {
    char ss[500];
    scanf("%s\n", ss);
    for (int j = 0; j < m; ++j) mapa[i][j] = ss[j] - '0';
  }
  for (int i = 0; i < 10; ++i) {
    int a, b;
    scanf("%d %d\n", &a, &b);
    mov[i] = {a, b};
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) visited[i][j] = -1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      dfs({i, j});
      dfs2({i, j});
    }
  while (q--) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        len[i][j] = 0;
        deg2[i][j] = deg[i][j];
      }
    queue<pair<int, int> > qq;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        if (deg2[i][j] == 0) qq.push({i, j});
    scanf("%s\n", s);
    int ll = strlen(s);
    suf[ll] = 0;
    for (int i = ll - 1; i >= 0; --i) {
      suf[i] = suf[i + 1] | (1 << (s[i] - '0'));
    }
    bool found = false;
    while (!qq.empty()) {
      auto x = qq.front();
      qq.pop();
      auto next = x + mov[mapa[x.first][x.second]];
      int pos = len[x.first][x.second];
      while (pos < ll && s[pos] - '0' == mapa[x.first][x.second]) ++pos;
      if (pos == ll) {
        found = true;
        break;
      }
      if (next.first < 0 || next.first >= n || next.second < 0 ||
          next.second >= m)
        continue;
      len[next.first][next.second] = max(len[next.first][next.second], pos);
      --deg2[next.first][next.second];
      if (visited[next.first][next.second] > 0) {
        int need = suf[len[next.first][next.second]];
        int have = visited[next.first][next.second];
        if (((~have) & (have ^ need)) == 0) {
          found = true;
          break;
        }
      } else {
        if (deg2[next.first][next.second] == 0) qq.push(next);
      }
    }
    if (found)
      puts("YES");
    else
      puts("NO");
  }
}
