#include <bits/stdc++.h>
using namespace std;
static int N;
static int M;
static int Q;
static int w[500000];
static int C[4096];
static int cost[4096];
static int ans[4096][101];
static int read10(void) {
  int x;
  cin >> x;
  return x;
}
static int read2(void) {
  static string tmp;
  cin >> tmp;
  assert((int)tmp.size() == N);
  int n = 0;
  for (int i = 0; i < (int)tmp.size(); i++) n = 2 * n + tmp[i] - '0';
  return n;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  N = read10();
  M = read10();
  Q = read10();
  for (int i = 0; i < N; i++) w[i] = read10();
  for (int i = 0; i < M; i++) C[read2()]++;
  for (int i = 0; i < (1 << N); i++) {
    for (int j = 0; j < N; j++)
      if (i & (1 << j)) cost[i] += w[N - 1 - j];
  }
  for (int i = 0; i < (1 << N); i++)
    for (int j = 0; j < (1 << N); j++)
      if (cost[i ^ j] < 101) ans[~i & ((1 << N) - 1)][cost[i ^ j]] += C[j];
  for (int i = 0; i < (1 << N); i++)
    for (int k = 1; k < 101; k++) ans[i][k] += ans[i][k - 1];
  for (int i = 0; i < Q; i++) {
    int t = read2();
    int k = read10();
    printf("%d\n", ans[t][k]);
  }
  return 0;
}
