#include <bits/stdc++.h>
using namespace std;
long long w[14];
long long n, m, q;
vector<vector<long long> > wu(1 << 12, vector<long long>(1205));
long long from_bin_string(string s) {
  long long ret = 0;
  long long pow = 1;
  for (long long t = 0; t < n; t++) {
    if (s[n - t - 1] == '1') ret += pow;
    pow *= 2ll;
  }
  return ret;
}
long long calc_wu(long long str1, long long str2) {
  long long ret = 0;
  for (long long i = 0; i < n; i++)
    ret += w[n - i - 1] * ((str1 & (1 << i)) == (str2 & (1 << i)));
  return ret;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (long long i = 0; i < n; i++) cin >> w[i];
  vector<long long> occur(1 << n);
  for (long long i = 0; i < m; i++) {
    string s;
    cin >> s;
    occur[from_bin_string(s)]++;
  }
  for (long long i = 0; i < (1 << n); i++) {
    for (long long j = 0; j < (1 << n); j++) {
      wu[i][calc_wu(i, j)] += occur[j];
    }
  }
  map<long long, long long>::iterator it, it_prev;
  for (long long i = 0; i < (1 << n); i++) {
    for (long long j = 1; j < 1205; j++) wu[i][j] += wu[i][j - 1];
  }
  for (long long i = 0; i < q; i++) {
    string ss;
    long long kk;
    cin >> ss >> kk;
    cout << wu[from_bin_string(ss)][kk] << '\n';
  }
  return 0;
}
