#include <bits/stdc++.h>
using namespace std;
long long f[5000], ans[5000][105];
string s;
long long n, m, q, c, t, kk;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  long long w[n];
  for (long long i = 0; i < n; i++) cin >> w[i];
  for (long long i = 0; i < m; i++) {
    cin >> s;
    reverse(s.begin(), s.end());
    t = 0;
    for (long long j = 0; j < n; j++)
      if (s[j] == '1') t += (1LL << j);
    f[t]++;
  }
  for (long long i = 0; i < (1LL << n); i++) {
    for (long long j = 0; j < (1LL << n); j++) {
      if (!f[j]) continue;
      c = 0;
      for (long long k = 0; k < n; k++)
        if ((i & (1LL << k)) == (j & (1LL << k))) c += w[n - 1 - k];
      if (c < 101) ans[i][c] += f[j];
    }
    for (long long j = 1; j < 101; j++) ans[i][j] += ans[i][j - 1];
  }
  for (long long i = 0; i < q; i++) {
    cin >> s >> kk;
    reverse(s.begin(), s.end());
    t = 0;
    for (long long j = 0; j < n; j++)
      if (s[j] == '1') t += (1LL << j);
    cout << ans[t][kk] << "\n";
  }
  return 0;
}
