#include <bits/stdc++.h>
using namespace std;
int rb() {
  while (true) {
    char c = getchar();
    if (c == '1') return 1;
    if (c == '0') return 0;
  }
}
int w[20];
const int mt = 300;
int val[mt];
int n, m, q, lim;
int rd() {
  int ret = 0;
  for (int i = 1; i <= n; i++) {
    ret = ret * 2 + rb();
  }
  return ret;
}
int cnt[5000];
int prp[5000][mt];
int gwu(int s, int t) {
  int r = 0;
  for (int i = 0; i < n; i++) {
    if ((s & (1 << i)) == (t & (1 << i))) r += w[n - i - 1];
  }
  return r;
}
void pnt(int s) {
  int tmp[20];
  for (int i = 0; i < n; i++) tmp[i] = s % 2, s /= 2;
  for (int i = n - 1; i >= 0; i--) printf("%d", tmp[i]);
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  int sm = 0;
  for (int i = 0; i < n; i++) scanf("%d", &w[i]), sm += w[i];
  sm = min(sm, 100);
  for (int i = 1; i <= m; i++) {
    int t = rd();
    cnt[t]++;
  }
  lim = 1 << n;
  for (int i = 0; i < lim; i++) {
    memset(val, 0, sizeof(val));
    for (int j = 0; j < lim; j++) {
      if (!cnt[j]) continue;
      int p = gwu(i, j);
      if (p > 100) continue;
      val[p] += cnt[j];
    }
    prp[i][0] = val[0];
    for (int j = 1; j <= 100; j++) {
      prp[i][j] = prp[i][j - 1] + val[j];
    }
  }
  while (q--) {
    int p = rd();
    int k;
    scanf("%d", &k);
    printf("%d\n", prp[p][k]);
  }
  return 0;
}
