#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, m, Q, sum, w[N], cnt[N], val[N][1222];
int calc(int a, int b) {
  int ret = 0;
  for (int i = 0; i < n; i++)
    if ((a & (1 << i)) == (b & (1 << i))) ret += w[i];
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    char ch[13];
    scanf("%s", ch);
    int s = 0;
    for (int j = n - 1; ~j; j--) s = s * 2 + ch[j] - '0';
    cnt[s]++;
  }
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j < (1 << n); j++)
      if (cnt[j]) val[i][calc(i, j)] += cnt[j];
  for (int i = 0; i < (1 << n); i++)
    for (int j = 1; j <= 100; j++) val[i][j] += val[i][j - 1];
  while (Q--) {
    char ch[13];
    scanf("%s", ch);
    int s = 0, t;
    for (int j = n - 1; ~j; j--) s = s * 2 + ch[j] - '0';
    scanf("%d", &t);
    printf("%d\n", val[s][t]);
  }
}
