#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 500000 + 10;
const int maxm = 20000 + 10;
const int mod = 1000000007;
int w[15], k[maxn], ans[maxn];
int v[4100], cnt[4100], number[4100];
pair<int, int> same_val[4100];
char s[15];
vector<int> query[4100];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 0; i < (1 << n); i++) {
    int tmp = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        continue;
      } else {
        tmp += w[j + 1];
      }
    }
    v[i] = tmp;
  }
  for (int i = 0; i < m; i++) {
    int val = 0;
    scanf("%s", s);
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') val += 1 << j;
    }
    cnt[val]++;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%s%d", s, &k[i]);
    int val = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') val += 1 << j;
    }
    query[val].push_back(i);
  }
  for (int i = 0; i < (1 << n); i++) {
    memset(number, 0, sizeof(number));
    int len = 0;
    for (int j = 0; j < (1 << n); j++) {
      int x = i ^ j;
      same_val[++len] = make_pair(v[x], cnt[j]);
    }
    sort(same_val + 1, same_val + 1 + len);
    for (int i = 1; i <= len; i++) {
      number[i] = number[i - 1] + same_val[i].second;
    }
    if (query[i].size()) {
      for (int j = 0; j < query[i].size(); j++) {
        int pos = upper_bound(same_val + 1, same_val + 1 + len,
                              make_pair(k[query[i][j]], inf)) -
                  same_val - 1;
        ans[query[i][j]] = number[pos];
      }
    }
  }
  for (int i = 1; i <= q; i++) {
    printf("%d\n", ans[i]);
  }
  return 0;
}
