#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c;
  do c = getchar(), f = c == '-' ? -1 : f;
  while (!isdigit(c));
  do x = (x << 3) + (x << 1) + c - '0', c = getchar();
  while (isdigit(c));
  return x * f;
}
int n, m, q, k, ans, t;
int a[10000020], b[10000020], v[10000020], pw[10000020];
int p[5000][520];
char s[15];
int main() {
  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 + 1);
    t = 0;
    for (int j = 1; j <= n; j++) {
      t = t * 2 + s[j] - '0';
    }
    b[t]++;
  }
  pw[0] = 1;
  for (int i = 1; i <= n + 1; i++) pw[i] = pw[i - 1] * 2;
  for (int i = 0; i < pw[n + 1]; i++)
    for (int j = 1; j <= n; j++)
      if (i & pw[j - 1]) v[i] += a[n - j + 1];
  for (int i = 0; i < pw[n + 1]; i++) {
    for (int j = 0; j < pw[n + 1]; j++) {
      t = (pw[n + 1] - 1) ^ (i ^ j);
      p[i][v[t]] += b[j];
    }
  }
  for (int i = 1; i <= q; i++) {
    scanf("%s", s + 1);
    int t = 0;
    for (int j = 1; j <= n; j++) {
      t = t * 2 + s[j] - '0';
    }
    scanf("%d", &k);
    ans = 0;
    for (int j = 0; j <= k; j++) ans += p[t][j];
    printf("%d\n", ans);
  }
  return 0;
}
