#include <bits/stdc++.h>
using namespace std;
int cnt[1 << 12];
pair<int, int> x[1 << 12];
int val[1 << 12];
int w[15];
int dp[1 << 12][1 << 12];
int main() {
  int n, m, q;
  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++) {
    char s[15] = {};
    scanf("%s", s);
    int now = 0;
    for (int j = 0; j < n; j++) {
      now = now * 2 + s[j] - '0';
    }
    cnt[now]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << (n - j - 1))) {
        sum += w[j];
      }
    }
    x[i] = make_pair(sum, i);
  }
  sort(x, x + (1 << n));
  int mask = (1 << n) - 1;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      dp[i][j] = cnt[i ^ (~x[j].second & mask)];
      if (j) dp[i][j] += dp[i][j - 1];
    }
  }
  for (int i = 0; i < (1 << n); i++) val[i] = x[i].first;
  while (q--) {
    char s[15] = {};
    int k;
    scanf("%s%d", s, &k);
    int now = 0;
    for (int i = 0; i < n; i++) {
      now = now * 2 + s[i] - '0';
    }
    int j = upper_bound(val, val + (1 << n), k) - val - 1;
    printf("%d\n", dp[now][j]);
  }
  return 0;
}
