#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1123456;
const int MAXINT = 2147483098;
const long long MAXLL = 9223372036854775258LL;
int w[MAXN];
char bit[500005][15];
char cur[MAXN];
int n, sz = 0;
vector<string> uniq;
string s[MAXN];
int mp[MAXN];
int ans[5000][105];
void go(char now, int len) {
  cur[len] = now;
  if (len == n) {
    int mask = 0;
    for (int i = 1; i <= n; ++i)
      if (cur[i] == '1') mask += (1 << (n - i));
    for (auto s : uniq) {
      int have = 0;
      int xui = 0;
      for (int j = 1; j <= n; ++j)
        if (s[j - 1] == '1') xui += (1 << (n - j));
      for (int j = 1; j <= n; ++j)
        if (s[j - 1] == cur[j]) have += w[j];
      ans[mask][min(101, have)] += mp[xui];
    }
    for (int i = 1; i <= 100; ++i) ans[mask][i] += ans[mask][i - 1];
    return;
  }
  go('0', len + 1);
  go('1', len + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int q, m;
  cin >> n >> m >> q;
  for (int i = 1; i <= n; ++i) cin >> w[i];
  for (int i = 1; i <= m; ++i) {
    cin >> s[i];
    int mask = 0;
    for (int j = 1; j <= n; ++j)
      if (s[i][j - 1] == '1') mask += (1 << (n - j));
    if (mp[mask] == 0) uniq.push_back(s[i]);
    mp[mask]++;
  }
  go('0', 1);
  go('1', 1);
  while (q--) {
    int mask = 0, k;
    for (int j = 1; j <= n; ++j) cin >> cur[j];
    for (int i = 1; i <= n; ++i)
      if (cur[i] == '1') mask += (1 << (n - i));
    cin >> k;
    cout << ans[mask][k] << '\n';
  }
  return 0;
}
