#include <bits/stdc++.h>
using namespace std;
int Q, m, n, a[10001], c[100001], ans, f[5001][101], d[1001];
char b[500001][13];
void dfs(int x, int now, int zong, int he) {
  if (x > n) {
    if (zong <= 100) f[he][zong] += c[now];
    return;
  }
  dfs(x + 1, now * 2 + 1, zong + (d[x] == 1 ? a[x] : 0), he);
  dfs(x + 1, now * 2, zong + (d[x] == 0 ? a[x] : 0), he);
}
int main() {
  int i, j, now, t, ha;
  char s[10001];
  scanf("%d%d%d", &n, &m, &Q);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= m; i++) {
    now = 0;
    scanf("%s", b[i] + 1);
    for (j = 1; j <= n; j++) {
      now = now * 2;
      if (b[i][j] == '1') now++;
    }
    c[now]++;
  }
  for (i = 0; i < (1 << n); i++) {
    now = i;
    ha = 0;
    for (j = 1; j <= n; j++) {
      d[j] = now % 2;
      ha = ha * 2 + d[j];
      now /= 2;
    }
    dfs(1, 0, 0, ha);
  }
  for (i = 0; i < (1 << n); i++)
    for (j = 1; j <= 100; j++) f[i][j] += f[i][j - 1];
  while (Q--) {
    scanf("%s%d", s + 1, &t);
    now = 0;
    for (i = 1; i <= n; i++) now = now * 2 + (s[i] == '1');
    printf("%d\n", f[now][t]);
  }
}
