#include <bits/stdc++.h>
#pragma GCC optimize("O3")
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
int n, m, q, w[15], M[1 << 12], ans[1 << 12][105], anss[1 << 12];
int f(string s) {
  int ans = 0;
  for (int i = 0; i < (int)((s).size()); i++) ans += (1LL << i) * (s[i] - '0');
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 1; i <= m; i++) {
    string s;
    cin >> s;
    int x = f(s);
    M[x]++;
  }
  for (int i = 0; i < (1LL << n); i++) {
    for (int bit = 0; bit < 12; bit++) {
      if (i & (1LL << bit)) {
      } else
        anss[i] += w[bit];
    }
  }
  for (int i = 0; i < (1LL << n); i++) {
    for (int j = 0; j < (1LL << n); j++) {
      int x = anss[(i ^ j)];
      if (x <= 100) ans[j][x] += M[i];
    }
  }
  for (int i = 0; i < (1LL << n); i++)
    for (int j = 1; j <= 100; j++) ans[i][j] += ans[i][j - 1];
  while (q--) {
    string s;
    cin >> s;
    int x = f(s);
    int k;
    cin >> k;
    cout << ans[x][k] << '\n';
  }
}
