#include <bits/stdc++.h>
using namespace std;
int mul(int a, int b) { return (a * b) % 998244353; }
int add(int a, int b) {
  a += b;
  if (a >= 998244353) a -= 998244353;
  return a;
}
int binary_expo(int base, int expo) {
  int res = 1;
  while (expo) {
    if (expo % 2) {
      res = mul(res, base);
    }
    expo /= 2;
    base = mul(base, base);
  }
  return res;
}
vector<int> v;
int w[13];
int ma[4097];
int ans[4097][102], cum[4097][102];
int freq[4097];
char s[13];
void generate_all(int n) {
  for (int i = 0; i < (1 << n); i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      if (i & (1 << j)) {
        sum += (1 << j);
      }
    }
    v.push_back(sum);
  }
  for (int i = 0; i < v.size(); i++) {
    ma[v[i]] = i;
  }
}
void calc_weights(int sz) {
  int n = v.size();
  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
      int s1 = v[i];
      int s2 = v[j];
      int sum = 0;
      for (int k = 0; k < sz; k++) {
        int b1 = (s1 & (1 << k));
        int b2 = (s2 & (1 << k));
        if (b1 == 0 and b2 == 0)
          sum += w[k];
        else if (b1 != 0 and b2 != 0)
          sum += w[k];
      }
      if (sum > 100) continue;
      ans[i][sum] += freq[j];
      if (j != i) ans[j][sum] += freq[i];
    }
  }
}
void solve() {
  int n, m, q;
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &q);
  generate_all(n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    int sum = 0;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        sum += (1 << j);
      }
    }
    int idx = ma[sum];
    freq[idx]++;
  }
  calc_weights(n);
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j <= 100; j++) {
      if (j == 0) {
        cum[i][j] = ans[i][j];
      } else
        cum[i][j] = cum[i][j - 1] + ans[i][j];
    }
  }
  while (q--) {
    int k;
    scanf("%s", s);
    int sum = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '1') sum += (1 << i);
    }
    int idx = ma[sum];
    scanf("%d", &k);
    printf("%d\n", cum[idx][k]);
  }
}
signed main() {
  int t;
  t = 1;
  while (t--) {
    solve();
  }
}
