#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, s, n, m, q, a[10005], B[10005], A[10005], G[10005][105];
char c[10005];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (i = n; i; i--) scanf("%d", &a[i]);
  for (i = 0; i < (1 << n); i++) {
    int x = i, j = 1, s = 0;
    while (x) {
      if (x & 1) s += a[j];
      x >>= 1;
      j++;
    }
    A[i] = min(101, s);
  }
  for (i = 1; i <= m; i++) {
    scanf("%s", c);
    s = 0;
    for (j = 0; j < n; j++) s = s * 2 + c[j] - '0';
    B[s]++;
  }
  for (i = 0; i < (1 << n); i++) {
    for (j = 0; j < (1 << n); j++) {
      if (!B[j]) continue;
      s = ((1 << n) - 1) ^ i ^ j;
      G[i][A[s]] += B[j];
    }
    for (j = 1; j <= 100; j++) G[i][j] += G[i][j - 1];
  }
  for (i = 1; i <= q; i++) {
    scanf("%s%d", c, &k);
    s = 0;
    for (j = 0; j < n; j++) s = s * 2 + c[j] - '0';
    printf("%d\n", G[s][k]);
  }
}
