#include <bits/stdc++.h>
using namespace std;
int n, m, ans, w[15], q;
int app[5000], pw[20], wu[5000][110];
int conv(char s[]) {
  int res = 0;
  for (int i = 0; i < strlen(s); ++i) {
    res *= 2;
    res += (s[i] == '1');
  }
  return res;
}
int diff(int i, int j) {
  int xr = i ^ j, res = 0;
  for (int k = 0; k < n; ++k) {
    if ((xr & pw[n - k - 1]) == 0) {
      res += w[k];
    }
  }
  return res;
}
signed main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &w[i]);
  }
  pw[0] = 1;
  for (int i = 1; i < n + 2; ++i) {
    pw[i] = pw[i - 1] + pw[i - 1];
  }
  for (int i = 0; i < m; ++i) {
    char s[n];
    scanf("%s", s);
    app[conv(s)]++;
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < (1 << n); ++j) {
      int ww = diff(i, j);
      if (ww > 100) {
        continue;
      }
      wu[j][ww] += app[i];
    }
  }
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 1; j <= 100; ++j) {
      wu[i][j] += wu[i][j - 1];
    }
  }
  for (int i = 0; i < q; ++i) {
    char s[n];
    int k;
    scanf("%s %d", s, &k);
    int x = conv(s);
    ans = wu[x][k];
    printf("%d\n", ans);
  }
}
