#include <bits/stdc++.h>
#pragma GCC optimize(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           \
    "-fdelete-null-pointer-checks,inline-functions-called-once,-funsafe-loop-optimizations,-fexpensive-optimizations,-foptimize-sibling-calls,-ftree-switch-conversion,-finline-small-functions,inline-small-functions,-frerun-cse-after-loop,-fhoist-adjacent-loads,-findirect-inlining,-freorder-functions,no-stack-protector,-fpartial-inlining,-fsched-interblock,-fcse-follow-jumps,-fcse-skip-blocks,-falign-functions,-fstrict-overflow,-fstrict-aliasing,-fschedule-insns2,-ftree-tail-merge,inline-functions,-fschedule-insns,-freorder-blocks,-fwhole-program,-funroll-loops,-fthread-jumps,-fcrossjumping,-fcaller-saves,-fdevirtualize,-falign-labels,-falign-loops,-falign-jumps,unroll-loops,-fsched-spec,-ffast-math,Ofast,inline,-fgcse,-fgcse-lm,-fipa-sra,-ftree-pre,-ftree-vrp,-fpeephole2", \
    3)
#pragma GCC target("avx", "sse2")
using namespace std;
int n, m, Q, val[20], need[4100], cnt[4100], ans[4100], qz[4100][4100], A;
char str[20];
pair<int, int> cst[4100][4100];
int main() {
  int i, j, k, o, p, q, l, r, mid;
  cin >> n >> m >> Q;
  A = (1 << n) - 1;
  for (i = 1; i <= n; i++) {
    scanf("%d", &val[i]);
  }
  for (i = 1; i < (1 << n); i++) {
    for (j = 1;; j++) {
      if ((1 << (j - 1)) & i) break;
    }
    need[i] = need[i ^ (1 << (j - 1))] + val[j];
  }
  for (i = 1; i <= m; i++) {
    scanf("%s", str + 1);
    o = 0;
    for (j = 1; j <= n; j++) {
      if (str[j] == '1') o |= (1 << (j - 1));
    }
    cnt[o]++;
  }
  for (i = 0; i < (1 << n); i++) {
    if (i == 1) i = 1;
    for (j = 0; j < (1 << n); j++) {
      cst[i][j] = make_pair(need[(i & j) | ((i | j) ^ A)], cnt[j]);
    }
    sort(cst[i], cst[i] + A + 1);
    qz[i][0] = cst[i][0].second;
    for (j = 1; j <= A; j++) qz[i][j] = qz[i][j - 1] + cst[i][j].second;
  }
  for (i = 1; i <= Q; i++) {
    scanf("%s", str + 1);
    o = 0;
    for (j = 1; j <= n; j++) {
      if (str[j] == '1') o |= (1 << (j - 1));
    }
    scanf("%d", &k);
    for (l = 0, r = A + 1; l < r;) {
      mid = ((l + r) >> 1);
      if (cst[o][mid].first > k)
        r = mid;
      else
        l = mid + 1;
    }
    if (!l)
      puts("0");
    else
      printf("%d\n", qz[o][l - 1]);
  }
}
