#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e3 + 10;
const int inf = 0x3f3f3f3f;
int ans[maxn][110], num[maxn], w[20];
int n, m, q;
char str[30];
int cal(int a, int b) {
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (((a >> i) & 1) == ((b >> i) & 1)) ret += w[n - i - 1];
  }
  return ret;
}
int get() {
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    ret = ret * 2 + str[i] - '0';
  }
  return ret;
}
void init() {
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = i; j < (1 << n); ++j) {
      int tmp = cal(i, j);
      if (tmp <= 100) {
        ans[i][tmp] += num[j];
        if (i == j) continue;
        ans[j][tmp] += num[i];
      }
    }
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 1; j <= 100; ++j) ans[i][j] += ans[i][j - 1];
  }
}
void solve() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; ++i) scanf("%d", w + i);
  while (m--) {
    scanf("%s", str);
    num[get()]++;
  }
  init();
  while (q--) {
    int k;
    scanf("%s%d", str, &k);
    printf("%d\n", ans[get()][k]);
  }
}
int main() {
  solve();
  return 0;
}
