#include <bits/stdc++.h>
using namespace std;
int n, m, q;
string mat[205];
pair<int, int> del[20];
vector<vector<pair<int, int> > > Cycle;
map<pair<int, int>, int> which;
vector<int> E[205 * 205];
pair<int, int> next(pair<int, int> t) {
  pair<int, int> nt = {t.first + del[(int)mat[t.first][t.second]].first,
                       t.second + del[(int)mat[t.first][t.second]].second};
  if (nt.first < 0 || nt.second < 0 || nt.first >= n || nt.second >= m)
    return t;
  return nt;
}
map<pair<int, int>, int> bio;
map<int, char> znak;
const pair<int, int> Bad = {-1, -1};
pair<int, int> CycleDFS(pair<int, int> t) {
  if (bio[t] == 2) return Bad;
  if (bio[t] == 1) {
    Cycle.push_back({});
    return t;
  }
  bio[t] = 1;
  pair<int, int> nt = CycleDFS(next(t));
  bio[t] = 2;
  if (nt == Bad) return Bad;
  Cycle.back().push_back(t);
  if (nt == t) return Bad;
  return nt;
}
int MakeDFS(pair<int, int> t) {
  if (bio[t]) return bio[t];
  bio[t] = (int)bio.size();
  znak[bio[t]] = (char)(mat[t.first][t.second] + '0');
  E[MakeDFS(next(t))].push_back(bio[t]);
  return bio[t];
}
bitset<15> Has[205 * 205];
string in;
bool CheckDFS(int id, int hi, bool flag = false) {
  if (flag)
    while (hi >= 0 && Has[id][in[hi] - '0']) --hi;
  else if (in[hi] == znak[id])
    --hi;
  if (hi < 0) return true;
  bool r = false;
  for (auto first : E[id]) r |= CheckDFS(first, hi);
  return r;
}
int main() {
  cin >> n >> m >> q;
  for (int i = (int)(0); i < (int)(n); ++i) cin >> mat[i];
  for (int i = (int)(0); i < (int)(10); ++i)
    cin >> del[i].first >> del[i].second;
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(m); ++j)
      mat[i][j] = (char)(mat[i][j] - '0');
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(m); ++j) {
      if (bio[{i, j}]) continue;
      CycleDFS({i, j});
    }
  bio.clear();
  for (int i = (int)(0); i < (int)(Cycle.size()); ++i)
    for (auto first : Cycle[i]) {
      which[first] = i + 1;
      bio[first] = i + 1;
      Has[i + 1][(int)mat[first.first][first.second]] = 1;
    }
  for (int i = (int)(0); i < (int)(n); ++i)
    for (int j = (int)(0); j < (int)(m); ++j) MakeDFS({i, j});
  for (int tt = (int)(0); tt < (int)(q); ++tt) {
    cin >> in;
    bool can = false;
    for (int i = (int)(0); i < (int)(Cycle.size()); ++i)
      if (CheckDFS(i + 1, (int)in.size() - 1, true)) can = true;
    if (can)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
