#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, M = 5e3 + 5;
int a[N][105], f[N], v[15];
char s[15];
int n, m, q;
int sl(char s[]) {
  int val = 0;
  for (int i = 0; i < n; i++) {
    val = (s[i] - '0') + val * 2;
  }
  return val;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", &v[n - i - 1]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    int val = sl(s);
    f[val]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      int val = 0;
      for (int k = 0; k < n; k++) {
        if ((i & (1 << k)) == (j & (1 << k))) val += v[k];
      }
      if (val <= 100) a[i][val] += f[j];
    }
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 1; j <= 100; j++) {
      a[i][j] += a[i][j - 1];
    }
  }
  while (q--) {
    int k;
    scanf("%s %d", s, &k);
    int val = sl(s);
    printf("%d\n", a[val][k]);
  }
  return 0;
}
