#include <bits/stdc++.h>
const int INF = 1e9, N = 1e5 + 1000, K = 50;
const int MAXN = (1 << 12);
int cnt[MAXN];
int pred[MAXN];
std::vector<std::pair<short, int>> dp[MAXN];
int32_t main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  int n, q, m;
  std::cin >> n >> q >> m;
  int curN = (1 << n);
  std::vector<int> w(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> w[i];
  }
  for (int j = 0; j < curN; ++j) {
    for (int i = 0; i < n; ++i) {
      if ((j >> i) & 1) {
        pred[j] += w[i];
      }
    }
  }
  for (int j = 0; j < q; ++j) {
    long long sum = 0;
    for (int i = 0; i < n; ++i) {
      char x;
      std::cin >> x;
      if (x == '1') {
        sum += (1 << i);
      }
    }
    cnt[sum]++;
  }
  for (int mask = 0; mask < curN; ++mask) {
    for (int mask2 = 0; mask2 < curN; ++mask2) {
      if (cnt[mask2] == 0) {
        continue;
      }
      int curCost = pred[(((mask ^ mask2) ^ (curN - 1)))];
      dp[mask].push_back({curCost, cnt[mask2]});
    }
    std::sort(dp[mask].begin(), dp[mask].end());
    for (int i = 1; i < dp[mask].size(); ++i) {
      dp[mask][i].second += dp[mask][i - 1].second;
    }
  }
  for (int i = 0; i < m; ++i) {
    short k = 0;
    int curMask = 0;
    std::string s;
    std::cin >> s >> k;
    for (int j = 0; j < n; ++j) {
      if (s[j] == '1') {
        curMask += (1 << j);
      }
    }
    auto it = std::upper_bound(dp[curMask].begin(), dp[curMask].end(),
                               std::make_pair(k, INF));
    if (it == dp[curMask].begin()) {
      std::cout << 0 << '\n';
      continue;
    }
    --it;
    std::cout << it->second << '\n';
  }
}
