#include <bits/stdc++.h>
using namespace std;
const int maxn = 4100;
int n, q, m, cur, COST, cnt;
int cost[maxn], have[maxn];
bitset<12> a;
int adj[maxn][101];
void Input() {
  cin >> n >> m >> q;
  for (int i = (1); i <= (n); ++i) cin >> cost[i];
  for (int i = (1); i <= (m); ++i) {
    cin >> a;
    ++have[a.to_ulong()];
  }
}
void calc(int id, int i) {
  if (i > n) {
    if (COST <= 100) adj[id][COST] += have[cur];
    return;
  }
  COST += cost[i] * ((id >> (n - i) & 1) == 0);
  cur <<= 1;
  calc(id, i + 1);
  COST -= cost[i] * ((id >> (n - i) & 1) == 0);
  COST += cost[i] * ((id >> (n - i) & 1) == 1);
  cur |= 1;
  calc(id, i + 1);
  cur >>= 1;
  COST -= cost[i] * ((id >> (n - i) & 1) == 1);
}
void Solve() {
  for (int i = 0; i < (1 << n); ++i) {
    cur = 0;
    cnt = 0;
    COST = 0;
    calc(i, 1);
    for (int j = (1); j <= (100); ++j) adj[i][j] += adj[i][j - 1];
  }
  int tmp, k;
  for (int i = (1); i <= (q); ++i) {
    cin >> a >> k;
    tmp = a.to_ulong();
    cout << adj[tmp][k] << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Input();
  Solve();
  return 0;
}
