#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int MAXN = 400009;
int w[16];
int s[5000];
int cnt[5000][1212];
int main() {
  memset(cnt, 0, sizeof(cnt));
  memset(s, 0, sizeof(s));
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; ++i) {
    scanf("%d", w + i);
  }
  for (int i = 0; i < m; ++i) {
    char ss[16];
    scanf("%s", ss);
    int temp = 0;
    for (int j = 0; j < n; ++j) {
      temp += (ss[j] - '0') << j;
    }
    s[temp]++;
  }
  for (int i = 0; i < 1 << n; ++i) {
    for (int j = 0; j < 1 << n; ++j) {
      int sum = 0;
      for (int k = 0; k < n; ++k) {
        if (((i >> k) & 1) == ((j >> k) & 1)) sum += w[k];
      }
      cnt[j][sum] += s[i];
    }
  }
  for (int i = 0; i < 1 << n; ++i) {
    for (int k = 1; k <= 1200; ++k) {
      cnt[i][k] += cnt[i][k - 1];
    }
  }
  while (q--) {
    char ss[16];
    int k;
    scanf("%s %d", ss, &k);
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += (ss[i] - '0') << i;
    }
    printf("%d\n", cnt[sum][k]);
  }
}
