#include <bits/stdc++.h>
using namespace std;
int n, m, q, di[100], dj[100];
struct cell {
  string s;
  int cycle;
  cell() {
    cycle = 0;
    s = "";
  }
} cel;
vector<cell> v;
int a[205][205];
bool vis[205][205], vis1[205][205], vis2[205][205];
int x, y, add;
bool check(int i, int j) { return i >= 0 && i < n && j >= 0 && j < m; }
void solve(int i, int j) {
  vis[i][j] = vis2[i][j] = 1;
  int b = a[i][j];
  int ni = i + di[b], nj = j + dj[b];
  if (!check(ni, nj)) {
    add = 1;
    cel.cycle |= (1 << b);
    vis[i][j] = 0;
    return;
  }
  if (vis[ni][nj]) {
    x = ni;
    y = nj;
    cel.cycle |= (1 << b);
    if (i == ni && j == nj) add = 1;
    vis[i][j] = 0;
    return;
  }
  solve(ni, nj);
  if (add == 0) {
    cel.cycle |= (1 << b);
    if (i == ni && j == nj) add = 1;
  } else
    cel.s += char(b + '0');
  vis[i][j] = 0;
  return;
}
char query[1 << 20];
int nums[10], remain, rem, num[10];
bool ok(cell& c) {
  int j = 0, b;
  for (int i = 0; i < c.s.size(); ++i) {
    if ((remain | c.cycle) == c.cycle) return 1;
    if (c.s[i] == query[j]) {
      b = query[j] - '0';
      --nums[b];
      if (nums[b] == 0) remain ^= (1 << b);
      ++j;
    }
  }
  if ((remain | c.cycle) == c.cycle) return 1;
  return 0;
}
int main() {
  memset(vis, 0, sizeof vis);
  memset(vis1, 0, sizeof vis1);
  memset(vis2, 0, sizeof vis2);
  cin >> n >> m >> q;
  char c;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> c;
      a[i][j] = c - '0';
    }
  }
  for (int i = 0; i < 10; ++i) cin >> di[i] >> dj[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      int b = a[i][j];
      int ni = i + di[b], nj = j + dj[b];
      if (check(ni, nj) && (ni != i || nj != j)) vis1[ni][nj] = 1;
    }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (!vis1[i][j]) {
        cel = cell();
        x = y = -1;
        add = 0;
        solve(i, j);
        reverse(cel.s.begin(), cel.s.end());
        v.push_back(cel);
      }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (!vis2[i][j]) {
        cel = cell();
        x = y = -1;
        add = 0;
        solve(i, j);
        reverse(cel.s.begin(), cel.s.end());
        v.push_back(cel);
      }
  }
  bool yes;
  for (int k = 0; k < q; ++k) {
    scanf("%s", query);
    for (int i = 0; i < 10; ++i) num[i] = 0;
    rem = 0;
    for (int j = 0; query[j] != '\0'; ++j) ++num[query[j] - '0'];
    for (int i = 0; i < 10; ++i)
      if (num[i]) rem |= (1 << i);
    yes = 0;
    for (int j = 0; j < v.size(); ++j) {
      remain = rem;
      for (int i = 0; i < 10; ++i) nums[i] = num[i];
      if (ok(v[j])) {
        yes = 1;
        break;
      }
    }
    if (yes)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
