#include <bits/stdc++.h>
using namespace std;
vector<int> cnt;
vector<int> w;
int n;
int f(int mask, int i) { return ((mask >> i) & 1); }
int f(string &s) {
  int ans = 0;
  for (int i = 0; i < s.size(); ++i) {
    ans = ans * 2 + s[i] - '0';
  }
  return ans;
}
int wu(int mask1, int mask2) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (f(mask1, i) == f(mask2, i)) {
      ans += w[n - i - 1];
    }
  }
  return ans;
}
vector<vector<int> > count1;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int m, q;
  cin >> n >> m >> q;
  cnt.resize(1 << n);
  w.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  count1.assign((1 << n), vector<int>(101, 0));
  for (int i = 0; i < m; ++i) {
    string s;
    cin >> s;
    ++cnt[f(s)];
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    for (int mask1 = 0; mask1 < (1 << n); ++mask1) {
      int q = wu(mask, mask1);
      if (q <= 100) {
        count1[mask][q] += cnt[mask1];
      }
    }
  }
  for (int mask = 0; mask < (1 << n); ++mask) {
    for (int i = 1; i < count1[mask].size(); ++i) {
      count1[mask][i] += count1[mask][i - 1];
    }
  }
  for (int i = 0; i < q; ++i) {
    string s;
    int k;
    cin >> s >> k;
    cout << count1[f(s)][k] << "\n";
  }
  return 0;
}
