#include <bits/stdc++.h>
using namespace std;
set<int> a;
multiset<int> ms;
char z[500500][15];
vector<int> w;
int n;
int gt(int id) {
  int ans = 0;
  for (int i = n - 1, c = 0; i >= 0; i--, c++)
    if (z[id][i] == '1') ans += (1 << c);
  return ans;
}
int val[(1 << 12) + 100][110];
vector<int> S;
int CNT[(1 << 12) + 100];
int main() {
  int n, m, q, wi;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) {
    scanf("%d", &wi);
    w.push_back(wi);
  }
  reverse(w.begin(), w.end());
  int no, j, c;
  for (int i = 0; i < m; i++) {
    scanf("%s", z[i]);
    no = 0;
    for (j = n - 1, c = 0; j >= 0; j--, c++)
      if (z[i][j] == '1') no += (1 << c);
    ms.insert(no);
    a.insert(no);
  }
  int cval, i, x, ck;
  for (set<int>::iterator it = a.begin(); it != a.end(); it++) {
    x = *it;
    CNT[x] = ms.count(x);
    S.push_back(x);
  }
  int SZ = S.size();
  for (i = 0; i < (1 << n); i++) {
    for (j = 0; j < SZ; j++) {
      x = S[j];
      cval = 0;
      for (ck = 0; ck < n; ck++) {
        if (((i >> ck) & 1) == ((x >> ck) & 1)) cval += w[ck];
      }
      if (cval <= 100) val[i][cval] += CNT[x];
    }
    for (j = 1; j <= 100; j++) val[i][j] += val[i][j - 1];
  }
  int k;
  char sq[15];
  while (q--) {
    scanf("%s", sq);
    no = 0;
    for (i = n - 1, c = 0; i >= 0; i--, c++) {
      if (sq[i] == '1') no += (1 << c);
    }
    scanf("%d", &k);
    printf("%d\n", val[no][k]);
  }
  return 0;
}
