#include <bits/stdc++.h>
using namespace std;
int wu[20], arr[(1 << 12) + 5], brr[(1 << 12) + 5][(1 << 12) + 5],
    crr[(1 << 12) + 5], drr[(1 << 12) + 5][105];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 0; i < n; i++) cin >> wu[i];
    while (m--) {
      string s1;
      cin >> s1;
      int val = 0, tr = 1;
      for (int i = n - 1; i >= 0; i--) {
        if (s1[i] == '1') val += tr;
        tr *= 2;
      }
      arr[val]++;
    }
    for (int i = 0; i < (1 << 12) + 5; i++) {
      int ele = i, val = 0;
      for (int j = n - 1; j >= 0; j--) {
        if (ele % 2 == 0) val += wu[j];
        ele /= 2;
      }
      crr[i] = val;
    }
    for (int i = 0; i < (1 << 12) + 5; i++) {
      for (int j = 0; j < (1 << 12) + 5; j++) {
        int ele = i ^ j;
        brr[i][j] = crr[ele];
        if (brr[i][j] <= 100) drr[i][brr[i][j]] += arr[j];
      }
    }
    for (int i = 0; i < (1 << 12) + 5; i++) {
      for (int j = 1; j <= 100; j++) drr[i][j] += drr[i][j - 1];
    }
    for (int i = 0; i < q; i++) {
      string s1;
      cin >> s1;
      int k;
      cin >> k;
      int val = 0, tr = 1;
      for (int j = n - 1; j >= 0; j--) {
        if (s1[j] == '1') val += tr;
        tr *= 2;
      }
      cout << drr[val][k] << "\n";
    }
  }
  cerr << '\n'
       << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n";
}
