#include <bits/stdc++.h>
using namespace std;
vector<int> w;
int stobin(string &s) {
  int a = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '1') a |= (1 << i);
  }
  return a;
}
int count(int a, int b) {
  int c = (a ^ b), res = 0;
  for (int i = 0; i < w.size(); i++) {
    if ((c & (1 << i)) == 0) res += w[i];
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, q, nn;
  cin >> n >> m >> q;
  nn = (1 << n);
  w.resize(n);
  vector<int> a(m);
  for (int i = 0; i < n; i++) cin >> w[i];
  string s;
  for (int i = 0; i < m; i++) {
    cin >> s;
    a[i] = stobin(s);
  }
  vector<vector<int> > cnt(nn, vector<int>(101));
  vector<int> c(nn);
  for (int i = 0; i < m; i++) {
    c[a[i]]++;
  }
  for (int i = 0; i < nn; i++) {
    for (int j = 0; j < nn; j++) {
      if (count(i, j) <= 100) cnt[i][count(i, j)] += c[j];
    }
  }
  int x, k, res = 0;
  for (int i = 0; i < q; i++) {
    cin >> s >> k;
    x = stobin(s);
    res = 0;
    for (int j = 0; j <= k; j++) {
      res += cnt[x][j];
    }
    cout << res << "\n";
  }
  return 0;
}
