#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
int sum[5000][110];
int w[5000];
int shu[5000];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = (0); i <= (n - 1); ++i) scanf("%d", &w[i]);
  char q1[20];
  for (int i = (1); i <= (m); ++i) {
    scanf("%s", q1);
    int x = 0;
    for (int j = (0); j <= (n - 1); ++j) {
      int w = q1[j] - '0';
      if (w) x += (1 << (j));
    }
    shu[x]++;
  }
  for (int i = (0); i <= ((1 << n) - 1); ++i)
    for (int j = (0); j <= ((1 << n) - 1); ++j) {
      if (!shu[j]) continue;
      int sum_1 = 0;
      for (int k = (0); k <= (n - 1); ++k)
        if ((i & (1 << k)) == (j & (1 << k))) {
          sum_1 += w[k];
          if (sum_1 > 100) break;
        }
      if (sum_1 <= 100) sum[i][sum_1] += shu[j];
    }
  char q2[20];
  int K;
  while (q--) {
    scanf("%s%d", q2, &K);
    int x = 0;
    for (int i = (0); i <= (n - 1); ++i) {
      int w = q2[i] - '0';
      if (w) x += (1 << (i));
    }
    long long ans = 0;
    for (int i = (0); i <= (K); ++i) ans += sum[x][i];
    printf("%I64d\n", ans);
  }
  return 0;
}
