#include <bits/stdc++.h>
using namespace std;
int n, m, q;
string s2;
char s[205][205];
int vis[205][205];
int dp[205 * 205][20];
int a[10];
int b[10];
vector<int> Q;
void dfs(int x, int y) {
  vis[x][y] = 1;
  int t = s[x][y] - '0';
  int p = m * x + y;
  int xx = x + a[t], yy = y + b[t];
  if (xx < 0 || xx >= n || yy < 0 || yy >= m)
    dp[p][t] = p;
  else {
    int pp = m * xx + yy;
    dp[p][t] = pp;
    if (!vis[xx][yy]) dfs(xx, yy);
    for (int i = 0; i < 10; i++)
      if (i != t) dp[p][i] = dp[pp][i];
  }
}
bool check() {
  int find;
  int len = s2.size();
  for (int j = 0; j < Q.size(); ++j) {
    find = Q[j];
    for (int k = 0; k < len; k++) {
      find = dp[find][s2[k] - '0'];
      if (find < 0) break;
    }
    if (find >= 0) return true;
  }
  return false;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < 10; i++) cin >> a[i] >> b[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (!vis[i][j]) {
        dfs(i, j);
        Q.push_back(m * i + j);
      }
    }
  }
  for (int i = 0; i < q; i++) {
    cin >> s2;
    if (check())
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
