#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
template <typename T>
T sqr(T x) {
  return x * x;
}
template <typename T>
void vout(T s) {
  cout << s << endl;
  exit(0);
}
int bp(int a, int n) {
  int res = 1;
  while (n) {
    if (n % 2) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
int translate(string s) {
  int res = 0;
  for (int i = 0; i < s.size(); i++) res |= (1ll << i) * (s[i] - '0');
  return res;
}
vector<int> kek[5001];
int sum[5001][101];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  string s;
  int k = 1ll << n;
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b[i];
  vector<int> a(k);
  for (int i = 0; i < m; i++) {
    cin >> s;
    a[translate(s)]++;
  }
  for (int i = 0; i < k; i++)
    for (int j = 0; j < k; j++) {
      int sc = 0;
      for (int i1 = 0; i1 < n; i1++) {
        int ra = (1ll << i1) & i;
        int rb = (1ll << i1) & j;
        if (ra == rb) sc += b[i1];
      }
      if (sc < 101) sum[i][sc] += a[j];
    }
  for (int i = 0; i < k; i++) {
    kek[i].resize(101);
    int sc = 0;
    for (int j = 0; j < 101; j++) {
      sc += sum[i][j];
      kek[i][j] = sc;
    }
  }
  while (q--) {
    int xe;
    cin >> s >> xe;
    int x = translate(s);
    int ans = kek[x][xe];
    cout << ans << "\n";
  }
  return 0;
}
