#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int a[202][202], mark[202][202], in[202][202], cyc[202][202];
pair<int, int> head[202][202];
int pres[202][202][11];
vector<pair<int, int> > heads;
pair<int, int> p[10];
int presq[1000001][10];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; ++j) a[i][j] = s[j - 1] - '0';
  }
  for (int i = 0; i <= 9; ++i) cin >> p[i].first >> p[i].second;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (!mark[i][j]) {
        int stx = i, sty = j, fr = 0;
        vector<pair<int, int> > tem;
        while (stx >= 1 && stx <= n && sty >= 1 && sty <= m &&
               !mark[stx][sty]) {
          tem.push_back(make_pair(stx, sty));
          if (fr) in[stx][sty]++;
          fr = 1;
          pres[i][j][a[stx][sty]] = 1;
          mark[stx][sty] = 1;
          auto cur = p[a[stx][sty]];
          stx += cur.first;
          sty += cur.second;
        }
        if (stx == i && sty == j) {
          heads.push_back(make_pair(i, j));
          for (auto xp : tem) {
            cyc[xp.first][xp.second] = 1;
            head[xp.first][xp.second] = make_pair(i, j);
          }
        }
        if (stx >= 1 && stx <= n && sty >= 1 && sty <= m) in[stx][sty]++;
      }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (!in[i][j]) {
        heads.push_back(make_pair(i, j));
      }
  while (q--) {
    string s;
    cin >> s;
    int sz = s.size();
    for (int i = 0; i <= sz; ++i)
      for (int j = 0; j <= 9; ++j) presq[i][j] = 0;
    for (int i = sz - 1; i >= 0; i--) {
      for (int j = 0; j <= 9; ++j) presq[i][j] = presq[i + 1][j];
      presq[i][s[i] - '0'] = 1;
    }
    string ans = "NO";
    for (auto xp : heads) {
      if (cyc[xp.first][xp.second]) {
        bool ff = 1;
        for (int i = 0; i <= 9; ++i)
          if (presq[0][i] > pres[xp.first][xp.second][i]) {
            ff = 0;
            break;
          }
        if (ff) {
          ans = "YES";
          break;
        }
      } else {
        int stx = xp.first, sty = xp.second, pos = 0;
        while (pos < sz && stx >= 1 && stx <= n && sty >= 1 && sty <= m &&
               !cyc[stx][sty]) {
          while (pos < sz && s[pos] - '0' == a[stx][sty]) pos++;
          auto cur = p[a[stx][sty]];
          stx += cur.first;
          sty += cur.second;
        }
        if (pos == sz) {
          ans = "YES";
          break;
        }
        if (stx >= 1 && stx <= n && sty >= 1 && sty <= m) {
          auto cur = head[stx][sty];
          stx = cur.first, sty = cur.second;
          bool ff = 1;
          for (int i = 0; i <= 9; ++i)
            if (presq[pos][i] > pres[stx][sty][i]) {
              ff = 0;
              break;
            }
          if (ff) {
            ans = "YES";
            break;
          }
        }
      }
    }
    cout << ans << '\n';
  }
}
