#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
const double pi = acos(-1.0);
const long long mod = 1000000007;
int n, m, q;
int cc[maxn];
int w[15];
struct qq {
  int id;
  int k, s, ans;
} tp[maxn];
bool cmp(qq a, qq b) { return a.id < b.id; }
bool cmp2(qq a, qq b) {
  if (a.s != b.s) return a.s < b.s;
  return a.k < b.k;
}
int va[5005], cnt[5005], id[5005], ct[5005];
bool cmp3(int i, int j) { return va[i] < va[j]; }
int main() {
  int i, j;
  scanf("%d %d %d", &n, &m, &q);
  for (i = 0; i < n; i++) scanf("%d", w + i);
  memset(cnt, 0, sizeof(cnt));
  for (i = 0; i < m; i++) {
    char c[15];
    scanf("%s", c);
    cc[i] = 0;
    for (j = 0; j < n; j++) cc[i] += (c[j] == '1' ? 1 : 0) << j;
    cnt[cc[i]]++;
  }
  for (i = 0; i < q; i++) {
    char c[15];
    scanf("%s %d", c, &tp[i].k);
    tp[i].id = i;
    tp[i].s = 0;
    for (j = 0; j < n; j++) tp[i].s += (c[j] == '1' ? 1 : 0) << j;
  }
  sort(tp, tp + q, cmp2);
  for (int ca = 0; ca < q;) {
    int cat;
    for (i = 0; i < (1 << n); i++) {
      int tmp = i ^ tp[ca].s;
      va[i] = 0;
      for (j = 0; j < n; j++)
        if (!(tmp >> j & 1)) va[i] += w[j];
      id[i] = i;
    }
    sort(id, id + (1 << n), cmp3);
    ct[0] = 0;
    for (i = 0; i < (1 << n); i++) ct[i + 1] = ct[i] + cnt[id[i]];
    for (cat = ca, j = 0; cat < q && tp[cat].s == tp[ca].s; cat++) {
      for (; j < (1 << n) && va[id[j]] <= tp[cat].k; j++)
        ;
      tp[cat].ans = ct[j];
    }
    ca = cat;
  }
  sort(tp, tp + q, cmp);
  for (i = 0; i < q; i++) printf("%d\n", tp[i].ans);
  return 0;
}
