#include <bits/stdc++.h>
using namespace std;
const int MAXM = 500005;
const int MAXN = 15;
const int N = 12;
int w[MAXN];
char query[MAXN];
char s[MAXN];
int n, m, q;
int transform(char* s) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = 2 * ans + (s[i] - '0');
  }
  return ans;
}
int cnt_set[(1 << N)];
int dif[(1 << N)][(1 << N)];
int get_dif(int a, int b) {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if ((a & 1) == (b & 1)) ans += w[i];
    a >>= 1;
    b >>= 1;
  }
  return ans;
}
vector<pair<int, int>> cnt_queries[(1 << N)];
int sol[MAXM];
const int MAXK = 101;
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = n - 1; i >= 0; i--) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s);
    int val = transform(s);
    cnt_set[val]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      dif[i][j] = get_dif(i, j);
    }
  }
  for (int i = 1; i <= q; i++) {
    scanf("%s", query);
    int p = transform(query);
    int k;
    scanf("%d", &k);
    cnt_queries[p].push_back({k, i});
  }
  for (int i = 0; i < (1 << n); i++) {
    vector<int> current(MAXK);
    for (int i = 0; i < MAXK; i++) current[i] = 0;
    for (int j = 0; j < (1 << n); j++) {
      if (dif[i][j] < MAXK) {
        current[dif[i][j]] += cnt_set[j];
      }
    }
    for (int i = 1; i < MAXK; i++) current[i] += current[i - 1];
    for (auto p : cnt_queries[i]) {
      sol[p.second] = current[p.first];
    }
  }
  for (int i = 1; i <= q; i++) printf("%d\n", sol[i]);
  return 0;
}
