#include <bits/stdc++.h>
using namespace std;
int n, q, m, w[15], cnt[4096], hv[4096][102], at;
char x[20];
int ta, tb;
void go(int a) {
  if (a == n) {
    hv[at][min(101, ta)] += cnt[tb];
  } else if (at & (1 << a)) {
    ta += w[a];
    tb |= 1 << a;
    go(a + 1);
    tb -= 1 << a;
    ta -= w[a];
    go(a + 1);
  } else {
    ta += w[a];
    go(a + 1);
    ta -= w[a];
    tb |= 1 << a;
    go(a + 1);
    tb -= 1 << a;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", w + i);
  while (m--) {
    ta = 0;
    scanf("%s", x);
    for (int i = 0; i < n; i++)
      if (x[i] == '1') ta += 1 << i;
    cnt[ta]++;
  }
  for (at = 0; at < (1 << n); at++) {
    ta = tb = 0;
    go(0);
    for (int i = 1; i <= 100; i++) hv[at][i] += hv[at][i - 1];
  }
  while (q--) {
    ta = 0;
    scanf("%s%d", x, &tb);
    for (int i = 0; i < n; i++)
      if (x[i] == '1') ta += 1 << i;
    printf("%d\n", hv[ta][tb]);
  }
  return 0;
}
