#include <bits/stdc++.h>
using namespace std;
const int N = 20;
int n, m, q, w[N], cnt[1 << 12];
char s[N];
inline void init() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    reverse(s, s + n);
    int tmp = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') tmp += (1 << i);
    }
    cnt[tmp]++;
  }
}
int sum[5005][205];
inline void solve() {
  for (int i = 0; i < (1 << 12); i++) {
    for (int j = 0; j < (1 << 12); j++) {
      if (cnt[j]) {
        int a = i, b = j, tmp = 0;
        for (int k = n - 1; k >= 0; k--) {
          int c = a % 2;
          a = a / 2;
          int d = b % 2;
          b = b / 2;
          if (c == d) tmp += w[k];
        }
        if (tmp <= 100) sum[i][tmp] += cnt[j];
      }
    }
  }
  for (int i = 1; i <= q; i++) {
    int k;
    scanf("%s%d", s, &k);
    reverse(s, s + n);
    int tmp = 0;
    for (int i = 0; i < n; i++)
      if (s[i] == '1') tmp += (1 << i);
    int ans = 0;
    for (int i = 0; i <= k; i++) ans += sum[tmp][i];
    printf("%d\n", ans);
  }
}
int main() {
  init();
  solve();
  return 0;
}
