#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5, M = 1e5, P = 1e9 + 7;
int n, m, q, k, res, w[15], vis[M];
long long ans[M][105];
char s[15], b[15];
map<int, int> v;
struct query {
  int s, k;
} Q[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i <= m; i++) {
    cin >> s + 1;
    res = 0;
    for (int j = n, k = 0; j >= 1; j--, k++)
      if (s[j] == '1') res |= 1 << k;
    v[res]++;
  }
  for (int i = 1; i <= q; i++) {
    cin >> b + 1 >> k;
    res = 0;
    for (int j = n, k = 0; j >= 1; j--, k++)
      if (b[j] == '1') res |= 1 << k;
    vis[res] = 1;
    Q[i].s = res, Q[i].k = k;
  }
  for (int S = 0; S < M; S++) {
    if (!vis[S]) continue;
    for (auto it : v) {
      int cur = 0, i = it.first;
      for (int j = n, k = 0; j >= 1; j--, k++) {
        if ((S >> k & 1) == (i >> k & 1)) cur += w[j];
      }
      if (cur > 100) continue;
      ans[S][cur] += it.second;
    }
  }
  for (int s = 0; s < M; s++) {
    for (int i = 1; i <= 100; i++) ans[s][i] += ans[s][i - 1];
  }
  for (int i = 1; i <= q; i++) {
    cout << ans[Q[i].s][Q[i].k] << '\n';
  }
  return 0;
}
