#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 100;
int cnt[maxn], a[maxn], ans[maxn][200];
char s[maxn];
int n, m, q;
int getint() {
  int num = 0;
  for (int i = 0; i <= n - 1; i++) num = num * 2 + s[i] - '0';
  return num;
}
int u = 0;
int getwi(int x, int y) {
  int num = 0;
  for (int i = n; i >= 1; i--) {
    if ((x & 1) == (y & 1)) num += a[i];
    x >>= 1, y >>= 1;
  }
  return num;
}
void solve() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    int o = getint();
    cnt[o]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      int o = getwi(i, j);
      if (o <= 100) ans[i][o] += cnt[j];
    }
  }
  for (int i = 1; i <= q; i++) {
    int k;
    scanf("%s%d", s, &k);
    int o = getint();
    int ss = 0;
    for (int j = 0; j <= k; j++) {
      ss += ans[o][j];
    }
    printf("%d\n", ss);
  }
}
int main() { solve(); }
