#include <bits/stdc++.h>
using namespace std;
map<string, int> f, reff;
int n, m, q, w[13], ans[4097][101];
string s;
string tob(int x) {
  string t = "";
  while (x > 0) {
    x % 2 == 0 ? t = "0" + t : t = "1" + t;
    x /= 2;
  }
  while (t.length() < n) {
    t = "0" + t;
  }
  return t;
}
int tod(string x) {
  int r = 0, v = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (x[i] == '1') r += v;
    v *= 2;
  }
  return r;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> w[i];
  while (m--) {
    getline(cin >> ws, s);
    f[s]++;
  }
  int maxnum = (1 << n) - 1;
  for (int i = 0; i <= maxnum; i++) {
    string tmp = tob(i);
    map<string, int>::iterator j;
    for (j = f.begin(); j != f.end(); j++) {
      int v = 0;
      for (int k = 0; k < n; k++)
        if (tmp[k] == j->first[k]) v += w[k];
      if (v <= 100) ans[i][v] += j->second;
    }
  }
  for (int i = 0; i <= maxnum; i++)
    for (int j = 1; j <= 100; j++) ans[i][j] += ans[i][j - 1];
  while (q--) {
    int kk;
    cin >> ws >> s >> kk;
    cout << ans[tod(s)][kk] << "\n";
  }
  return 0;
}
