#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, q, k, e, t, a, l, ss, A;
  cin >> n >> m >> q;
  int s, S;
  long long d;
  vector<int> St;
  int V[4096][101], K[101], Sk[4096], w[n];
  bool G[4096];
  for (int i = 0; i < 4096; i++) {
    for (int y = 0; y <= 100; y++) {
      V[i][y] = -1;
    }
    Sk[i] = 0;
    G[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < m; i++) {
    scanf("%I64d", &d);
    l = 1;
    a = 0;
    for (int y = n - 1; y >= 0; y--) {
      if (d % 2 == 1) {
        a += l;
      }
      l *= 2;
      d /= 10;
    }
    if (Sk[a] == 0) {
      St.push_back(a);
    }
    Sk[a]++;
  }
  ss = St.size();
  for (int i = 0; i < q; i++) {
    scanf("%I64d", &d);
    scanf("%d", &k);
    l = 1;
    a = 0;
    for (int y = n - 1; y >= 0; y--) {
      if (d % 2 == 1) {
        a += l;
      }
      l *= 2;
      d /= 10;
    }
    if (G[a] == 0) {
      G[a] = 1;
      for (int y = 0; y <= 100; y++) {
        K[y] = 0;
      }
      for (int y = 0; y < ss; y++) {
        s = a;
        S = St[y];
        e = 0;
        for (int u = n - 1; u >= 0; u--) {
          if (S % 2 == s % 2) {
            e += w[u];
          }
          S /= 2;
          s /= 2;
        }
        if (e <= 100) {
          K[e] += Sk[St[y]];
        }
      }
      l = 0;
      for (int y = 0; y <= 100; y++) {
        l += K[y];
        V[a][y] = l;
      }
    }
    cout << V[a][k] << "\n";
  }
  return 0;
}
