#include <bits/stdc++.h>
using namespace std;
int n, m, q, k, w[100];
int c[1 << 12], ans[1 << 12][101];
char s[100];
vector<pair<int, int> > vc;
int to_int(char *s, int n) {
  int x = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') x |= (1 << i);
  }
  return x;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    int x = to_int(s, n);
    c[x]++;
  }
  for (int S = 0; S < (1 << n); S++) {
    int v = 0;
    for (int i = 0; i < n; i++) {
      if ((S >> i) & 1) v += w[i];
    }
    vc.push_back(pair<int, int>(v, S));
  }
  sort(vc.begin(), vc.end());
  for (int S = 0; S < (1 << n); S++) {
    int pos = 0;
    for (int v = 0; v <= 100; v++) {
      ans[S][v] = (v == 0) ? 0 : ans[S][v - 1];
      while (pos < (1 << n) && vc[pos].first <= v) {
        int S2 = vc[pos].second, S3 = 0;
        for (int i = 0; i < n; i++) {
          int c = (S >> i) & 1;
          c = ((S2 >> i) & 1) ? c : 1 ^ c;
          S3 |= (c << i);
        }
        ans[S][v] += c[S3];
        pos++;
      }
    }
  }
  while (q--) {
    scanf("%s %d", s, &k);
    int x = to_int(s, n);
    printf("%d\n", ans[x][k]);
  }
}
