#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int w[15];
char str[14];
int a[500005];
int cnt[5003];
int ans[1 << 13][200];
int main() {
  int i, j;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &q);
  for (i = 0; i < n; i++) scanf("%d", &w[i]);
  for (i = 1; i <= m; i++) {
    scanf("%s", str);
    a[i] = 0;
    for (j = 0; j < n; j++) {
      if (str[j] == '1') a[i] += (1 << j);
    }
    cnt[a[i]]++;
  }
  for (int msk = 0; msk < (1 << n); msk++) {
    for (int val = 0; val < (1 << n); val++) {
      if (cnt[val] == 0) continue;
      int now = 0;
      for (i = 0; i < n; i++) {
        if ((val & (1 << i)) == (msk & (1 << i))) now += w[i];
      }
      if (now <= 100) ans[msk][now] += cnt[val];
    }
  }
  for (int msk = 0; msk < (1 << n); msk++) {
    for (i = 1; i <= 100; i++) ans[msk][i] += ans[msk][i - 1];
  }
  int k;
  while (q--) {
    scanf("%s", str);
    scanf("%d", &k);
    int msk = 0;
    for (i = 0; i < n; i++) {
      if (str[i] == '1') msk += (1 << i);
    }
    printf("%d\n", ans[msk][k]);
  }
}
