#include <bits/stdc++.h>
using namespace std;
long double eps = (long double)1 / 1e9;
long long inf = LLONG_MAX, mod1 = 1e9 + 7, mod2 = 998244353;
long long sqr(long long a) { return a * a; }
long long qb(long long a) { return a * a * a; }
long long gcd(long long a, long long b) { return !a ? b : gcd(b % a, a); }
long long binpow(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod
                    : sqr(binpow(a, b / 2, mod)) % mod)
           : 1;
}
long long binmult(long long a, long long b, long long mod) {
  return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod
                    : (2 * binmult(a, b / 2, mod)) % mod)
           : 0;
}
int a[13], kl[4100], sum[4100], ans[4100][101];
vector<pair<int, int> > vc[4100];
string st, ex;
unordered_map<string, int> ump;
int main() {
  cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0);
  int n, m, q, i, j, k, x;
  cin >> n >> m >> q;
  for (i = 1; i <= n; i++) cin >> a[i], ex += "0";
  for (i = 0; i < (1 << n); i++) {
    st = ex;
    for (j = 0; j < n; j++)
      (i & (1 << j)) ? st[n - j - 1] = '1' : sum[i] += a[n - j];
    ump[st] = i;
  }
  while (m--) {
    cin >> st;
    kl[ump[st]]++;
  }
  for (i = 0; i < (1 << n); i++) {
    for (j = 0; j < (1 << n); j++)
      if (kl[j]) vc[i].push_back({sum[i ^ j], kl[j]});
    sort(vc[i].begin(), vc[i].end());
    x = k = 0;
    for (j = 0; j <= 100; j++) {
      while (x < vc[i].size() && vc[i][x].first <= j) k += vc[i][x].second, x++;
      ans[i][j] = k;
    }
  }
  while (q--) {
    cin >> st >> k;
    cout << ans[ump[st]][k] << '\n';
  }
  return 0;
}
