#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int f[5000] = {0};
  int n, m, q;
  cin >> n >> m >> q;
  int w[n];
  for (int i = 0; i < n; ++i) {
    cin >> w[i];
  }
  string s;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    int v = 0;
    int mul = 1;
    for (int j = n - 1; j >= 0; --j) {
      if (s[j] == '1') {
        v += mul;
      }
      mul *= 2;
    }
    f[v]++;
  }
  int kv[5000][200] = {};
  for (int i = 0; i < 5000; ++i) {
    for (int j = 0; j < 5000; ++j) {
      if (f[j] != 0) {
        int v = 0;
        int h = i, r = j;
        for (int k = n - 1; k >= 0; --k) {
          if (h % 2 == r % 2) {
            v += w[k];
          }
          h /= 2;
          r /= 2;
        }
        if (v < 200) kv[i][v] += f[j];
      }
    }
  }
  for (int i = 0; i < 5000; ++i) {
    for (int j = 1; j < 200; ++j) {
      kv[i][j] += kv[i][j - 1];
    }
  }
  while (q) {
    --q;
    string ss;
    cin >> ss;
    int ff;
    cin >> ff;
    int v = 0;
    int mul = 1;
    for (int j = n - 1; j >= 0; --j) {
      if (ss[j] == '1') {
        v += mul;
      }
      mul *= 2;
    }
    cout << kv[v][ff] << "\n";
  }
}
