#include <bits/stdc++.h>
using namespace std;
int conv(string s) {
  int ans = 0;
  int n = s.size() - 1;
  for (int i = 0; i < s.size(); i++) {
    ans += (s[i] == '1') * (1 << n);
    n--;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> w;
  for (int i = 0; i < n; i++) {
    int u;
    cin >> u;
    w.push_back(u);
  }
  vector<int> s;
  vector<int> cnt(5000);
  for (int i = 0; i < m; i++) {
    string ss;
    cin >> ss;
    int k = conv(ss);
    cnt[k] += 1;
    if (cnt[k] == 1) {
      s.push_back(k);
    }
  }
  reverse(w.begin(), w.end());
  vector<vector<int> > dp(5000, vector<int>(101));
  for (int i = 0; i < s.size(); i++) {
    int u = s[i];
    for (int j = 0; j < 1 << n; j++) {
      int ans = 0;
      for (int k = 0; k < n; k++) {
        int pt = 1 << k;
        if ((pt & j) == (pt & u)) {
          ans += w[k];
        }
      }
      if (ans > 100) {
        continue;
      }
      dp[j][ans] += cnt[u];
    }
  }
  while (q--) {
    string ss;
    int u;
    cin >> ss >> u;
    int k = conv(ss);
    int ans = 0;
    for (int i = 0; i <= u; i++) {
      ans += dp[k][i];
    }
    cout << ans << '\n';
  }
}
