#include <bits/stdc++.h>
using namespace std;
const int maxn = 210;
int n, m, Q;
int dx[20], dy[20];
char s[maxn][maxn];
char cmd[1000010];
int sum[1000010][10];
int vis[maxn][maxn], VIS[maxn][maxn];
int A[maxn][maxn][10], B[maxn][maxn][10];
int c[300];
int d[300];
void dfs() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x = i, y = j;
      vector<int> G1, G2;
      if (vis[x][y]) continue;
      vis[x][y] = i * m + j;
      d[s[x][y] - '0']++;
      for (int k = 0; k < 200000; k++) {
        G1.push_back(x);
        G2.push_back(y);
        int X = x + dx[s[x][y] - '0'], Y = y + dy[s[x][y] - '0'];
        if (X >= 0 && Y >= 0 && X < n && Y < m) x = X, y = Y;
        if (vis[x][y] == i * m + j + n * m) break;
        if (vis[x][y] != i * m + j)
          vis[x][y] = i * m + j, d[s[x][y] - '0']++;
        else
          vis[x][y] = i * m + j + n * m, c[s[x][y] - '0']++, d[s[x][y] - '0']--;
      }
      for (int k = 0; k < G1.size(); k++) {
      }
      int bo = 1;
    }
}
int Solve() {
  scanf("%s", cmd);
  int L = strlen(cmd);
  for (int k = 0; k <= 9; k++) sum[L][k] = 0;
  for (int i = L - 1; i >= 0; i--) {
    for (int k = 0; k <= 9; k++) sum[i][k] = sum[i + 1][k];
    sum[i][cmd[i] - '0']++;
  }
  memset(vis, -1, sizeof(vis));
  memset(VIS, 0, sizeof(VIS));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int x = i, y = j;
      if (VIS[x][y]) continue;
      int pos = 0;
      memset(c, 0, sizeof(c));
      for (int k = 0; k < 200000; k++) {
        VIS[x][y] = 1;
        if (s[x][y] == cmd[pos]) pos++;
        int X = x + dx[s[x][y] - '0'], Y = y + dy[s[x][y] - '0'];
        if (X >= 0 && Y >= 0 && X < n && Y < m) x = X, y = Y;
        if (vis[x][y] == i * m + j + n * m) break;
        if (vis[x][y] != i * m + j)
          vis[x][y] = i * m + j;
        else
          vis[x][y] = i * m + j + n * m, c[s[x][y] - '0']++;
      }
      int bo = 1;
      for (int k = 0; k <= 9; k++)
        if (sum[pos][k] && !c[k]) bo = 0;
      if (bo) return puts("YES"), 0;
    }
  puts("NO");
}
int main() {
  cin >> n >> m >> Q;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < 10; i++) scanf("%d%d", &dx[i], &dy[i]);
  while (Q--) Solve();
  return 0;
}
