#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("-ffloat-store")
using namespace std;
clock_t time_p = clock();
void aryanc403() {
  time_p = clock() - time_p;
  cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
class cmp {
 public:
  bool operator()(long long int a, long long int b) { return a > b; }
};
void add(map<long long int, long long int> &m, long long int x,
         long long int n) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt == m.end())
    m.insert(make_pair(x, n));
  else
    jt->second += n;
}
void del(map<long long int, long long int> &m, long long int x) {
  map<long long int, long long int>::iterator jt;
  jt = m.find(x);
  if (jt->second == 1)
    m.erase(jt);
  else
    jt->second--;
}
bool cmp(const pair<long long int, long long int> &a,
         const pair<long long int, long long int> &b) {
  return a.first < b.first || (a.first == b.first && a.second < b.second);
}
const long long int INF = 0xFFFFFFFFFFFFFFFL;
const long long int mod = 1000000007L;
long long int T, n, i, m, j, k, in, l, q;
vector<long long int> a;
vector<long long int>::iterator it;
long long int cnt[5005], val;
long long int ans[5005][105];
long long int dp[5005][105];
long long int w[15];
bool vis[5005];
void solve(long long int t) {
  long long int v = 0;
  vis[t] = true;
  for (i = 0; i < (5001); ++i) {
    if (cnt[i]) {
      long long int cst = 0;
      for (j = 0; j < (15); ++j) {
        if ((i & (1 << j)) == (t & (1 << j))) {
          cst += w[j];
        }
      }
      if (cst <= 102) dp[t][cst] += cnt[i];
    }
  }
  long long int val = 0;
  for (i = 0; i < (103); ++i) {
    val += dp[t][i];
    dp[t][i] = val;
  }
}
long long int bin(long long int t) {
  if (t == 0) return 0;
  return (bin(t / 10) * 2) + t % 10;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> q;
  for (i = 0; i < (n); ++i) {
    cin >> w[n - i - 1];
  }
  for (i = 0; i < (m); ++i) {
    cin >> in;
    cnt[bin(in)]++;
  }
  while (q--) {
    cin >> in >> k;
    val = bin(in);
    if (vis[val] == false) {
      solve(val);
    }
    cout << dp[val][k] << '\n';
  }
  aryanc403();
  return 0;
}
