#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f;
const int MAXN = 1e2 + 10;
const int N = 5e3 + 10;
const int P = 1e9 + 7;
const long double eps = 1e-6;
int n;
int m;
int q;
int k;
string s;
string t;
int w[N];
int value[N];
int num[N];
int ans[N][110];
int sum[N][110];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i <= m; i++) {
    cin >> s;
    int tmp = 0;
    for (int j = 0; j <= n - 1; j++) {
      if (s[j] == '1') tmp += (1 << (n - 1 - j));
    }
    num[tmp]++;
  }
  for (int i = 1; i <= (1 << n) - 1; i++) {
    for (int j = 0; j <= n - 1; j++) {
      if (i & (1 << (n - j - 1))) {
        value[i] += w[j + 1];
      }
    }
    value[i] = min(101, value[i]);
  }
  for (int i = 0; i <= (1 << n) - 1; i++) {
    if (!num[i]) continue;
    for (int j = 0; j <= (1 << n) - 1; j++) {
      int tmp = i ^ j ^ ((1 << n) - 1);
      ans[tmp][value[j]] += num[i];
    }
  }
  for (int i = 0; i <= (1 << n) - 1; i++) {
    sum[i][0] = ans[i][0];
    for (int j = 1; j <= 100; j++) {
      sum[i][j] = sum[i][j - 1] + ans[i][j];
    }
  }
  for (int i = 1; i <= q; i++) {
    cin >> t >> k;
    int tmp = 0;
    for (int j = 0; j <= n - 1; j++) {
      if (t[j] == '1') tmp += (1 << (n - 1 - j));
    }
    cout << sum[tmp][k] << endl;
  }
  return 0;
}
