#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long infLL = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 12 + 5;
const int maxs = (1 << 6) + 5;
const int maxk = 100 + 5;
int n, m, q;
int w[maxn];
char s[maxn];
int v1[maxs], v2[maxs];
int f[maxs][maxs][maxk];
void init() {
  for (int S = 0; S < (1 << (n / 2)); ++S)
    for (int i = 0; i < (n / 2); ++i)
      if ((~S >> i) & 1) v1[S] += w[n / 2 - i - 1];
  for (int S = 0; S < (1 << (n - n / 2)); ++S)
    for (int i = 0; i < (n - n / 2); ++i)
      if ((~S >> i) & 1) v2[S] += w[n - i - 1];
}
int main(int argc, char *argv[]) {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < (n); ++i) scanf("%d", &w[i]);
  init();
  while (m--) {
    scanf("%s", s);
    int T1 = 0, T2 = 0;
    for (int i = 0; i < (n / 2); ++i) T1 = (T1 << 1) | (s[i] - '0');
    for (int i = 0; i < (n - n / 2); ++i) T2 = (T2 << 1) | (s[n / 2 + i] - '0');
    for (int S = 0; S < (1 << (n / 2)); ++S) {
      int k = v1[S ^ T1];
      if (k < maxk) ++f[S][T2][k];
    }
  }
  for (int S = 0; S < (maxs); ++S)
    for (int T = 0; T < (maxs); ++T)
      for (int k = (1); k <= (maxk - 1); ++k) f[S][T][k] += f[S][T][k - 1];
  while (q--) {
    int k, ret = 0;
    scanf("%s%d", s, &k);
    int S1 = 0, S2 = 0;
    for (int i = 0; i < (n / 2); ++i) S1 = (S1 << 1) | (s[i] - '0');
    for (int i = 0; i < (n - n / 2); ++i) S2 = (S2 << 1) | (s[n / 2 + i] - '0');
    for (int T = 0; T < (1 << (n - n / 2)); ++T) {
      int v = k - v2[S2 ^ T];
      if (v >= 0) ret += f[S1][T][v];
    }
    printf("%d\n", ret);
  }
  return 0;
}
