#include <bits/stdc++.h>
using namespace std;
int n, q, m;
int w[13];
int cnt[1 << 12];
int sum[205];
int ans[1 << 12][101];
int main(void) {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d%*c", &w[i]);
  }
  char ss[20];
  for (int i = 0; i < m; i++) {
    scanf("%s", ss);
    int cn = 0;
    for (int j = 0; j < n; j++) {
      if (ss[j] == '1') cn += (1 << j);
    }
    cnt[cn]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    memset(sum, 0, sizeof(sum));
    for (int j = 0; j < (1 << n); j++) {
      int sc = 0;
      for (int k = 0; k < n; k++) {
        if ((j >> k & 1) == (i >> k & 1)) {
          sc += w[k];
        }
      }
      sum[min(sc, 101)] += cnt[j];
    }
    ans[i][0] = sum[0];
    for (int j = 0; j < 100; j++) {
      sum[j + 1] += sum[j];
      ans[i][j + 1] = sum[j + 1];
    }
  }
  fgets(ss, 18, stdin);
  for (int i = 0; i < q; i++) {
    int cn = 0;
    fgets(ss, 18, stdin);
    for (int j = 0; j < n; j++) {
      if (ss[j] == '1') cn += (1 << j);
    }
    int k = 0;
    for (int j = n + 1; j <= n + 3; j++) {
      if (ss[j] >= '0' && ss[j] <= '9') {
        k *= 10;
        k += (ss[j] - '0');
      } else
        break;
    }
    printf("%d\n", ans[cn][k]);
  }
  return 0;
}
