#include <bits/stdc++.h>
using namespace std;
inline void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string digits = "0123456789";
int mp[int(4096)][int(4096)];
int s[int(4096)], sum[int(4096)];
int w[12];
void solve() {
  int n, m, q, x;
  string str;
  cin >> n >> m >> q;
  for (int i = 0; i < n; i++) cin >> w[n - 1 - i];
  for (int i = 0; i < m; i++) {
    cin >> str;
    x = stoi(str, NULL, 2);
    s[x]++;
  }
  for (int i = 0; i < int(4096); i++)
    for (int k = 0; k < 12; k++)
      if (((i >> k) & 1) == 0) sum[i] += w[k];
  for (int i = 0; i < int(4096); i++)
    for (int j = 0; j < int(4096); j++)
      if (sum[i ^ j] <= 100) {
        mp[i][sum[i ^ j]] += s[j];
      }
  for (int i = 0; i < int(4096); i++)
    for (int k = 1; k <= 100; k++) mp[i][k] += mp[i][k - 1];
  for (int k; q > 0; q--) {
    cin >> str >> k;
    x = stoi(str, NULL, 2);
    cout << mp[x][k] << '\n';
  }
}
