#include <bits/stdc++.h>
using namespace std;
int n, m, q, w[14], k, ans[1 << 13][110], a[1 << 13], cnt[1 << 13];
char s[14];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = n; i >= 1; i--) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i <= 1 << n; i++) {
    int x = i, j = 1, sum = 0;
    while (x) {
      if (x & 1) {
        sum += w[j];
      }
      j++;
      x >>= 1;
    }
    a[i] = min(101, sum);
  }
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    int t = 0;
    for (int i = 0; i < n; i++) {
      t = t * 2 + s[i] - '0';
    }
    cnt[t]++;
  }
  for (int i = 0; i <= 1 << n; i++) {
    for (int j = 0; j <= 1 << n; j++) {
      if (!cnt[j]) continue;
      int t = ((1 << n) - 1) ^ i ^ j;
      ans[i][a[t]] += cnt[j];
    }
    for (int j = 1; j <= 100; j++) {
      ans[i][j] = ans[i][j] + ans[i][j - 1];
    }
  }
  while (q--) {
    scanf("%s%d", s, &k);
    int t = 0;
    for (int i = 0; i < n; i++) {
      t = t * 2 + s[i] - '0';
    }
    printf("%d\n", ans[t][k]);
  }
  return 0;
}
