#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int INF = 2147483600;
const int MAXN = 600010;
int N, M, Q;
int T[(1 << 12) + 10];
struct que {
  int k, id;
  que(int a = 0, int b = 0) {
    k = a;
    id = b;
  }
};
int fg[(1 << 12) + 10][111];
int ans[MAXN + 1];
int a[14];
char str[14];
vector<que> vec[(1 << 12) + 10];
int main() {
  N = read(), M = read(), Q = read();
  for (int i = 1; i <= N; i++) a[N - i] = read();
  for (int i = 1; i <= M; i++) {
    scanf("%s", str);
    int x = 0;
    for (int j = 0; j < N; j++) x = (x << 1) + (str[j] == '1');
    T[x]++;
  }
  for (int i = 1; i <= Q; i++) {
    scanf("%s", str);
    int x = 0;
    for (int j = 0; j < N; j++) x = (x << 1) + (str[j] == '1');
    int tmp = read();
    vec[x].push_back(que(tmp, i));
  }
  for (int i = 0; i < (1 << N); i++) {
    if (!vec[i].size()) continue;
    for (int j = 0; j < (1 << N); j++) {
      if (!T[j]) continue;
      int res = 0;
      for (int k = 0; k < N; k++)
        if (((i >> k) & 1) == ((j >> k) & 1)) res += a[k];
      if (res > 100) continue;
      fg[i][res] += T[j];
    }
  }
  for (int i = 0; i < (1 << N); i++) {
    if (!vec[i].size()) continue;
    for (int j = 1; j <= 100; j++) fg[i][j] += fg[i][j - 1];
    for (int j = 0; j < vec[i].size(); j++)
      ans[vec[i][j].id] = fg[i][vec[i][j].k];
  }
  for (int i = 1; i <= Q; i++) printf("%d\n", ans[i]);
  return 0;
}
