#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using namespace std;
int w[20], cnt[5000], state[5000], num[5005][105];
char str[50];
int main() {
  int n, m, q;
  scanf("%d %d %d", &n, &m, &q);
  for (int i = 1; i < n + 1; ++i) scanf("%d", &w[i]);
  int statecnt = 1;
  for (int i = 0; i < m; ++i) {
    char c;
    int x = 0;
    scanf("%s", str);
    for (int j = 0; j < n; ++j) {
      c = str[j];
      x = (x << 1) + c - '0';
    }
    if (!cnt[x]) state[statecnt++] = x;
    cnt[x]++;
  }
  int end = 1 << n;
  for (int i = 0; i < end; ++i) {
    for (int j = 1; j < statecnt; ++j) {
      int u = i, v = state[j], sum = 0;
      for (int k = n; k >= 1; --k) {
        if ((u & 1) == (v & 1)) sum += w[k];
        if (sum > 100) break;
        u >>= 1, v >>= 1;
      }
      if (sum <= 100) num[i][sum] += cnt[state[j]];
    }
  }
  for (int i = 0; i < q; ++i) {
    char c;
    int x = 0;
    scanf("%s", str);
    for (int j = 0; j < n; ++j) {
      c = str[j];
      x = (x << 1) + c - '0';
    }
    int top;
    scanf("%d", &top);
    int ans = 0;
    for (int i = 0; i < top + 1; ++i) ans += num[x][i];
    printf("%d\n", ans);
  }
  return 0;
}
