#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int w[500007];
int cnt[8199];
int ans[8199][1207];
int sum[8199][1207];
char s[17];
int toint() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') ans += (1 << i);
  }
  return ans;
}
int fun1(int a, int b) {
  int temp = a ^ b;
  int now = 1;
  int sum = 0;
  while (temp) {
    if ((temp & 1) == 0) sum += w[now];
    temp >>= 1;
    now++;
  }
  while (now <= n) {
    sum += w[now++];
  }
  return sum;
}
void fun() {
  int maxy = (1 << n) - 1;
  for (int i = 0; i <= maxy; i++) {
    for (int j = 0; j <= maxy; j++) {
      if (cnt[j] == 0) continue;
      int now = fun1(i, j);
      ans[i][now] += cnt[j];
    }
    for (int j = 1; j <= 100 * n; j++) {
      ans[i][j] += ans[i][j - 1];
    }
  }
  return;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    cnt[toint()]++;
  }
  fun();
  while (q--) {
    memset(s, 0, sizeof(s));
    int k;
    scanf("%s", s);
    scanf("%d", &k);
    printf("%d\n", ans[toint()][k]);
  }
  return 0;
}
