#include <bits/stdc++.h>
using namespace std;
const int maxn = (1 << 12);
int cnt[maxn];
pair<int, int> res[maxn][maxn];
int pr[maxn][maxn];
int w[13];
int len;
int bsearch(int i, int k) {
  int l = 0, r = len;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    if (res[i][mid].first <= k)
      l = mid;
    else
      r = mid;
  }
  return l;
}
bool cmp(pair<int, int> a, pair<int, int> b) { return a.first < b.first; }
void counting_sort(int i) {
  vector<int> cnts[1205];
  for (int j = 0; j < len; j++) {
    cnts[res[i][j].first].push_back(res[i][j].second);
  }
  int j = 0;
  for (int k = 0; k < 1204; k++) {
    while (!cnts[k].empty()) {
      res[i][j] = {k, cnts[k].back()};
      cnts[k].pop_back();
      j++;
    }
  }
}
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  len = (1 << n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[n - i - 1]);
  }
  for (int i = 0; i < m; i++) {
    int num = 0;
    for (int j = 0; j < n; j++) {
      char c = getchar();
      while (c != '0' && c != '1') {
        c = getchar();
      }
      num *= 2;
      num += (c - '0');
    }
    cnt[num]++;
  }
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) {
      int ans = 0;
      for (int k = 0; k < n; k++) {
        if (((1 << k) & i) == ((1 << k) & j)) ans += w[k];
      }
      res[i][j] = {ans, cnt[j]};
    }
    counting_sort(i);
    pr[i][0] = res[i][0].second;
    for (int j = 1; j < (1 << n); j++) {
      pr[i][j] = pr[i][j - 1] + (res[i][j].second);
    }
  }
  for (int i = 0; i < q; i++) {
    int num = 0;
    for (int j = 0; j < n; j++) {
      char c = getchar();
      while (c != '0' && c != '1') {
        c = getchar();
      }
      num *= 2;
      num += (c - '0');
    }
    int k;
    scanf("%d", &k);
    int ind = bsearch(num, k);
    printf("%d\n", pr[num][ind]);
  }
  return 0;
}
