#include <bits/stdc++.h>
const long double eps = 0.00000001;
const long long MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
using namespace std;
long long ans;
int n, m, q;
int w[15];
int cnt[4100];
long long dp[4100][102];
int to(string second) {
  int num = 0;
  for (int i = 0, st = 1; i < n; ++i, st *= 2) num += st * (second[i] - '0');
  return num;
}
int main() {
  fflush(stdin);
  cout << fixed, cout.precision(18);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j;
  cin >> n >> m >> q;
  for (i = 0; i < n; ++i) cin >> w[i];
  for (i = 0; i < m; ++i) {
    string second;
    cin >> second;
    int num = to(second);
    cnt[num]++;
  }
  for (i = 0; i < 4096; ++i) {
    for (j = 0; j < 4096; ++j) {
      int sum = 0;
      int a = i, b = j;
      for (int st = 0; st < n; ++st) {
        if ((a % 2) == (b % 2)) sum += w[st];
        a /= 2;
        b /= 2;
      }
      if (sum <= 100) dp[i][sum] += cnt[j];
    }
  }
  for (i = 0; i < q; ++i) {
    string second;
    int k;
    cin >> second >> k;
    int num = to(second);
    long long sum = 0;
    for (j = 0; j <= k; ++j) sum += dp[num][j];
    cout << sum << "\n";
    ;
  }
}
