#include <bits/stdc++.h>
using namespace std;
const int N = 500010;
const int MOD = 1000000007;
int n, m, q;
char s[14];
int f[(1 << 12) + 10][(1 << 12) + 10], w[13], freq[(1 << 12) + 10];
int v[(1 << 12) + 10][100 * 14];
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &w[i]);
  }
  for (int i = 0; i < m; ++i) {
    scanf("%s", s);
    int val = 0;
    for (int j = 0; j < n; ++j) {
      val += (s[j] - '0') * (1 << j);
    }
    freq[val]++;
  }
  for (int msk = 0; msk < (1 << n); ++msk) {
    for (int go = 0; go < (1 << n); ++go) {
      for (int bit = 0; bit < n; ++bit) {
        f[msk][go] += (((go & (1 << bit)) == (msk & (1 << bit))) * w[bit]);
      }
    }
  }
  for (int msk = 0; msk < (1 << n); ++msk) {
    for (int go = 0; go < (1 << n); ++go) {
      v[msk][f[msk][go]] += freq[go];
    }
    for (int j = 1; j <= 1300; ++j) {
      v[msk][j] += v[msk][j - 1];
    }
  }
  for (int k, i = 0; i < q; ++i) {
    scanf("%s%d", s, &k);
    int cur = 0;
    for (int j = 0; j < n; ++j) {
      cur += (1 << j) * (s[j] - '0');
    }
    printf("%d\n", v[cur][k]);
  }
  return 0;
}
