#include <bits/stdc++.h>
using namespace std;
int vec[10005][101];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(vec, 0, sizeof(vec));
  long long n, m, q;
  cin >> n >> m >> q;
  vector<long long> A((n));
  for (long long i = 0; i < n; i++) cin >> A[i];
  ;
  vector<long long> B;
  long long val = 1 << n;
  vector<long long> ma(val, 0);
  for (long long i = 0; i < (m); i++) {
    string(s);
    cin >> (s);
    ;
    int res = 0;
    for (auto j : s) res = 2 * res + (j - '0');
    if (ma[res] == 0) {
      B.push_back(res);
    }
    ma[res]++;
  }
  vector<long long> vals(val, 0);
  for (long long i = 0; i < (val); i++) {
    for (long long j = 0; j < (n); j++) {
      if ((i >> j) & 1) vals[i] += A[n - j - 1];
    }
  }
  for (long long i = 0; i < (val); i++) {
    for (long long j = 0; j < (B.size()); j++) {
      long long vector = (~(i ^ B[j])) & (val - 1);
      long long v = vals[vector];
      if (v <= 100) vec[i][v] += ma[B[j]];
    }
  }
  for (long long i = 0; i < (val); i++) {
    for (long long j = 0; j < (101); j++)
      vec[i][j] += (j - 1 >= 0 ? vec[i][j - 1] : 0);
  }
  for (long long i = 0; i < (q); i++) {
    string(s);
    cin >> (s);
    ;
    int res = 0;
    for (auto j : s) res = 2 * res + (j - '0');
    long long k;
    cin >> k;
    cout << vec[res][k] << endl;
  }
  return 0;
}
