#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
                     "no-stack-protector")
#pragma GCC optimize("Ofast,no-stack-protector")
using namespace std;
const int MAXN = (int)5e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const int MAXS = 32 * 1024 * 1024;
char buf[MAXS], *ch;
void read(int &x) {
  while (*ch <= 32) ++ch;
  for (x = 0; *ch >= '0'; ++ch) x = x * 10 + *ch - '0';
}
void std_init() {
  ch = buf - 1;
  fread(buf, 1, MAXS, stdin);
}
int a[MAXN], cnt[1 << 12][105], _cnt[1 << 12], add[2][12], k[MAXN];
vector<int> num[12];
int lz[1 << 12];
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int n, m, q, w[33], x;
  string s;
  cin >> n >> m >> q;
  for (unsigned int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (unsigned int i = 0; i < m; i++) {
    cin >> s;
    for (int j = 0; j < s.size(); ++j) {
      a[i] <<= 1;
      a[i] |= s[j] - '0';
    }
    ++_cnt[a[i]];
  }
  for (unsigned int i = 0; i < 1 << n; i++) {
    for (unsigned int j = 0; j < n; j++) {
      if (!(i >> j & 1)) {
        lz[i] += w[n - j - 1];
      }
    }
  }
  for (unsigned int i = 0; i < 1 << n; i++) {
    for (unsigned int j = 0; j < 1 << n; j++) {
      if (lz[i ^ j] <= 100) cnt[i][lz[i ^ j]] += _cnt[j];
    }
  }
  for (unsigned int i = 0; i < 1 << n; i++) {
    for (unsigned int j = 1; j < 101; j++) {
      cnt[i][j] += cnt[i][j - 1];
    }
  }
  for (unsigned int i = 0; i < q; i++) {
    cin >> s >> x;
    int aa = 0;
    for (int j = 0; j < s.size(); ++j) {
      aa <<= 1;
      aa |= s[j] - '0';
    }
    cout << cnt[aa][x] << endl;
  }
  return 0;
}
