#include <bits/stdc++.h>
using namespace std;
int freq[1 << 15], a[15], sums[1 << 15][2005], n;
string t;
int toint() {
  int ret = 0;
  for (auto c : t) ret = ret * 2 + (c - '0');
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < n; cin >> a[i++])
    ;
  for (int i = m; i--; ++freq[toint()]) cin >> t;
  for (int x = 0; x < (1 << n); ++x) {
    for (int mask = 0; mask < (1 << n); ++mask) {
      int sum = 0;
      for (int j = 0; j < n; ++j)
        if (!((x >> j & 1) ^ (mask >> j & 1))) sum += a[n - 1 - j];
      sums[x][sum] += freq[mask];
    }
  }
  for (int i = 1, k; i <= q; ++i) {
    cin >> t >> k;
    int x = toint();
    cout << accumulate(sums[x], sums[x] + k + 1, 0) << '\n';
  }
}
