#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m, q, w[105], k, pref[5000][105], used[5000], cnt[5000];
char s[N][13], t[13];
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%s", s[i]);
    int x = 0, pw = 1;
    for (int j = 0; j < n; j++) {
      x += (s[i][j] - '0') * pw;
      pw <<= 1;
    }
    cnt[x]++;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%s", t);
    scanf("%d", &k);
    int x = 0, pw = 1;
    for (int j = 0; j < n; j++) {
      x += (t[j] - '0') * pw;
      pw <<= 1;
    }
    if (!used[x]) {
      for (int j = 0; j < (1 << n); j++) {
        pw = 1;
        int sum = 0;
        for (int r = 0; r < n; r++) {
          if (pw & j && t[r] == '1') sum += w[r];
          if (!(pw & j) && t[r] == '0') sum += w[r];
          pw <<= 1;
        }
        if (sum <= 100) {
          pref[x][sum] += cnt[j];
        }
      }
      for (int j = 1; j <= 100; j++) pref[x][j] += pref[x][j - 1];
      used[x] = 1;
    }
    printf("%d\n", pref[x][k]);
  }
}
