#include <bits/stdc++.h>
using namespace std;
int num[1 << 12], ans[1 << 12][110], w[14];
int n, m, q;
int tran(char ss[]) {
  int x = 0;
  for (int j = n; j >= 1; --j) {
    if (ss[j] == '1') {
      x |= (1 << (n - j));
    }
  }
  return x;
}
int main() {
  char ss[13];
  while (~scanf("%d%d%d", &n, &m, &q)) {
    memset(num, 0, sizeof(num));
    memset(ans, 0, sizeof(ans));
    memset(w, 0, sizeof(w));
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &w[i]);
    }
    for (int i = 1; i <= m; ++i) {
      scanf("%s", ss + 1);
      ++num[tran(ss)];
    }
    int tol = (1 << n) - 1;
    for (int i = 0; i <= tol; ++i) {
      for (int j = 0; j <= tol; ++j) {
        if (num[j]) {
          int val = 0;
          for (int k = 0; k < n; ++k) {
            int tem = (1 << k);
            if ((i & tem) == (j & tem)) {
              val += w[n - k];
            }
          }
          if (val <= 100) {
            ans[i][val] += num[j];
          }
        }
      }
    }
    for (int i = 0; i <= tol; ++i) {
      for (int j = 0; j <= 100; ++j) {
        ans[i][j] += ans[i][j - 1];
      }
    }
    int cost;
    for (int i = 1; i <= q; ++i) {
      scanf(" %s%d", ss + 1, &cost);
      printf("%d\n", ans[tran(ss)][cost]);
    }
  }
  return 0;
}
