#include <bits/stdc++.h>
using namespace std;
int w[100], cnt[100010], d[5000][110];
char sir[100];
int main() {
  int n, m, q, t;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  scanf("\n");
  for (int i = 1; i <= m; i++) {
    scanf("%s\n", sir);
    int nr = 0;
    for (int j = 0; j < n; j++)
      if (sir[j] == '1') nr += (1 << j);
    cnt[nr]++;
  }
  int lim = (1 << n);
  for (int mask1 = 0; mask1 < lim; mask1++) {
    for (int mask2 = 0; mask2 < lim; mask2++) {
      int s = 0;
      for (int bit = 0; bit < n; bit++) {
        int mask = mask1 ^ mask2;
        if (!(mask & (1 << bit))) s += w[bit];
      }
      if (s <= 100) d[mask1][s] += cnt[mask2];
    }
    for (int i = 1; i <= 100; i++) d[mask1][i] += d[mask1][i - 1];
  }
  for (int i = 1; i <= q; i++) {
    scanf("%s %d\n", sir, &t);
    int nr = 0;
    for (int j = 0; j < n; j++)
      if (sir[j] == '1') nr += (1 << j);
    printf("%d\n", d[nr][t]);
  }
  return 0;
}
