#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000000;
const double pi = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int kol_vo, m1, q, dd, now;
  cin >> kol_vo >> m1 >> q;
  vector<int> v(kol_vo);
  for (int c = 0; c < kol_vo; c++) cin >> v[c];
  string a;
  vector<int> dop(4100);
  for (int c = 0; c < m1; c++) {
    now = 0;
    cin >> a;
    dd = 1;
    reverse(a.begin(), a.end());
    for (int i = 0; i < kol_vo; i++) {
      now += (int(a[i]) - int('0')) * dd;
      dd *= 2;
    }
    dop[now]++;
  }
  map<int, vector<pair<int, int> > > m;
  vector<pair<int, int> > ask(q);
  set<int> st;
  int k;
  for (int c = 0; c < q; c++) {
    now = 0;
    cin >> a;
    dd = 1;
    reverse(a.begin(), a.end());
    for (int i = 0; i < kol_vo; i++) {
      now += (int(a[i]) - int('0')) * dd;
      dd *= 2;
    }
    cin >> k;
    ask[c].first = now;
    ask[c].second = k;
  }
  vector<int> need(101);
  for (int c = 0; c < q; c++) {
    now = ask[c].first;
    k = ask[c].second;
    if (st.find(now) != st.end()) {
      pair<int, int> help;
      help.first = k;
      help.second = inf;
      auto g = upper_bound(m[now].begin(), m[now].end(), help) - 1;
      cout << g->second << "\n";
    } else {
      memset(&need[0], 0, sizeof(need[0]) * need.size());
      for (int i = 0; i < 4100; i++) {
        if (dop[i] == 0) continue;
        int kol = 0;
        for (int j = 0; j < kol_vo; j++) {
          if (((i >> j) & 1) == ((now >> j) & 1)) kol += v[kol_vo - j - 1];
        }
        if (kol > 100) continue;
        need[kol] += dop[i];
      }
      for (int i = 0; i <= 100; i++) {
        if (need[i] == 0) continue;
        m[now].push_back({i, need[i]});
      }
      for (int i = 1; i < m[now].size(); i++) {
        m[now][i].second = m[now][i - 1].second + m[now][i].second;
      }
      pair<int, int> help;
      help.first = k;
      help.second = inf;
      auto g = upper_bound(m[now].begin(), m[now].end(), help) - 1;
      cout << g->second << "\n";
      st.insert(now);
    }
  }
  return 0;
}
