#include <bits/stdc++.h>
using namespace std;
const int size = 12;
long long dp[(1 << size) + 10][110];
long long freq[(1 << size) + 10];
long long n, q, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  long long w[n];
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  string s;
  int r;
  int mask;
  while (m--) {
    cin >> s;
    ;
    mask = 0;
    for (int i = n - 1; i >= 0; i--) {
      r = n - i - 1;
      if (s[i] == '1') mask |= (1 << r);
    }
    freq[mask]++;
  }
  int curr = 0;
  int a, b;
  for (int i = 0; i < (1 << n); i++) {
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      curr = 0;
      for (int k = 0; k < n; k++) {
        a = i & (1 << k);
        b = j & (1 << k);
        if (a == b) {
          curr += w[n - 1 - k];
        }
      }
      if (curr <= 100) {
        dp[i][curr] += freq[j];
      }
    }
    for (int j = 1; j <= 100; j++) {
      dp[i][j] += dp[i][j - 1];
    }
  }
  int k;
  char ch;
  while (q--) {
    cin >> s;
    cin >> k;
    mask = 0;
    for (int i = n - 1; i >= 0; i--) {
      r = n - i - 1;
      if (s[i] == '1') mask |= (1 << r);
    }
    cout << dp[mask][k] << "\n";
  }
  return 0;
}
