#include <bits/stdc++.h>
using namespace std;
int INF = 0x3f3f3f3f;
long long mod = 1e9 + 7;
const int N = 205;
int a[N][N];
int dx[10], dy[10];
pair<int, int> dp[N][N][10];
int vis[N][N];
vector<pair<int, int>> E;
int n, m, q;
void dfs(int x, int y) {
  vis[x][y] = 1;
  int t = a[x][y];
  int tx = x + dx[t];
  int ty = y + dy[t];
  if (tx >= 1 && tx <= n && ty >= 1 && ty <= m) {
    dp[x][y][t] = {tx, ty};
    if (vis[tx][ty] == 0) {
      dfs(tx, ty);
    }
    for (int i = 0; i < 10; i++) {
      if (i != t) dp[x][y][i] = dp[tx][ty][i];
    }
  } else {
    dp[x][y][t] = {x, y};
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%1d", &a[i][j]);
    }
  }
  for (int i = 0; i < 10; i++) {
    scanf("%d%d", &dx[i], &dy[i]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (vis[i][j] == 0) {
        dfs(i, j);
        E.push_back({i, j});
      }
    }
  }
  while (q--) {
    string s;
    cin >> s;
    for (int i = 0; i < E.size(); i++) {
      int x = E[i].first, y = E[i].second;
      for (int k = 0; k < s.size(); k++) {
        pair<int, int> tmp = dp[x][y][s[k] - '0'];
        if (tmp.first == 0) {
          goto M1;
        }
        x = tmp.first, y = tmp.second;
      }
      puts("YES");
      goto M2;
    M1:;
    }
    puts("NO");
  M2:;
  }
  return 0;
}
