#include <bits/stdc++.h>
using namespace std;
int w[20], cnt[5000], sum[5000][105], vis[5000][5005], base[20];
int main() {
  int n, m, q, k;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> w[i];
  base[0] = 1;
  for (int i = 1; i < n; i++) base[i] = 2 * base[i - 1];
  char s[20];
  while (m--) {
    scanf("%s", s);
    int tmp = 0;
    for (int i = 0; i < n; i++) tmp += (s[i] - '0') * base[i];
    cnt[tmp]++;
  }
  int bits = 1 << n;
  for (int i = 0; i < bits; i++) {
    for (int j = 0; j < bits; j++) {
      if (cnt[j] == 0) continue;
      int tmp = i ^ j, v = 0;
      tmp = (~tmp) + bits;
      for (int k = 0; k < n; k++) {
        if ((tmp & base[k])) v += w[k];
      }
      if (v <= 100) sum[i][v] += cnt[j];
    }
  }
  for (int i = 0; i < bits; i++) {
    for (int j = 1; j <= 100; j++) sum[i][j] += sum[i][j - 1];
  }
  while (q--) {
    scanf("%s %d", s, &k);
    int tmp = 0;
    for (int i = 0; i < n; i++) tmp += (s[i] - '0') * base[i];
    printf("%d\n", sum[tmp][k]);
  }
  return 0;
}
