#include <bits/stdc++.h>
using namespace std;
const int Maxn = 4200;
const int inf = 2147483647;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
  return x * f;
}
int n, m, q, w[15], v[Maxn], cnt[Maxn], sum[Maxn][102];
vector<int> h[Maxn][102];
int main() {
  n = read(), m = read(), q = read();
  for (int i = n - 1; i >= 0; i--) w[i] = read();
  for (int i = 0; i < (1 << n); i++) {
    v[i] = 0;
    for (int j = 0; j < n; j++)
      if ((1 << j) & i) v[i] += w[j];
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= m; i++) {
    char s[15];
    scanf("%s", s + 1);
    int t = 0;
    for (int i = n; i; i--) t += ((s[i] - '0') << (n - i));
    cnt[t]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      int x = (1 << n) - 1 - (i ^ j);
      if (v[x] <= 100) h[i][v[x]].push_back(j);
    }
    for (int j = 0; j <= 100; j++) {
      if (j)
        sum[i][j] = sum[i][j - 1];
      else
        sum[i][j] = 0;
      for (int k = 0; k < h[i][j].size(); k++) sum[i][j] += cnt[h[i][j][k]];
    }
  }
  while (q--) {
    char s[15];
    scanf("%s", s + 1);
    int k, t = 0;
    for (int i = n; i; i--) t += ((s[i] - '0') << (n - i));
    scanf("%d", &k);
    printf("%d\n", sum[t][k]);
  }
}
