#include <bits/stdc++.h>
using namespace std;
int val[20];
int visit[10000];
int cnt[10000];
int spr[5000][101];
int tt;
string mp[5000];
string change(int n, int len) {
  string ss = "";
  char s;
  while (n) {
    s = n % 2 + '0';
    n /= 2;
    ss = s + ss;
  }
  tt = ss.size();
  tt = len - ss.size();
  while (tt) {
    ss = '0' + ss;
    tt--;
  }
  return ss;
}
int main() {
  int n, q, m;
  int sum = 0;
  scanf("%d%d%d", &n, &q, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &val[i]);
  }
  char str1[20];
  for (int i = 0; i < q; i++) {
    sum = 0;
    scanf("%s", str1);
    for (int j = 0; j < n; j++) {
      sum *= 2;
      sum += str1[j] - '0';
    }
    cnt[sum]++;
  }
  string s1, s2;
  for (int i = 0; i < (1 << n); i++) {
    mp[i] = change(i, n);
  }
  for (int i = 0; i < (1 << n); i++) {
    s1 = mp[i];
    for (int j = 0; j < (1 << n); j++) {
      if (cnt[j]) {
        sum = 0;
        s2 = mp[j];
        for (int z = 0; z < n; z++) {
          if (s1[z] == s2[z]) {
            sum += val[z];
            if (sum > 100) break;
          }
        }
        if (sum <= 100) spr[i][sum] += cnt[j];
      }
    }
  }
  char zz[20];
  int num = 0;
  int k;
  int ans;
  int co;
  for (int z = 0; z < m; z++) {
    scanf("%s", zz);
    scanf("%d", &k);
    ans = 0;
    co = 0;
    for (int i = 0; i < n; i++) {
      co *= 2;
      co += zz[i] - '0';
    }
    for (int i = 0; i <= k; i++) {
      ans += spr[co][i];
    }
    printf("%d\n", ans);
  }
  return 0;
}
