#include <bits/stdc++.h>
using namespace std;
char s[15];
int w[15];
int cnt[4096];
int dp[4096][105];
int cost[4096];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  reverse(w, w + n);
  for (int j = 0; j < 4096; j++) {
    int res = 0;
    for (int i = 0; i < n; i++) {
      if (!((j >> i) & 1)) res += w[i];
    }
    cost[j] = res;
  }
  for (int i = 1; i <= m; i++) {
    scanf("%s", s + 1);
    int b = 1, res = 0;
    for (int j = n; j >= 1; j--) {
      if (s[j] == '1') res += b;
      b *= 2;
    }
    cnt[res]++;
  }
  for (int i = 0; i < 4096; i++) {
    for (int j = 0; j < 4096; j++) {
      if (!cnt[j]) continue;
      int k = i ^ j;
      if (cost[k] <= 100) dp[i][cost[k]] += cnt[j];
    }
  }
  for (int i = 0; i < 4096; i++) {
    for (int j = 1; j <= 100; j++) {
      dp[i][j] += dp[i][j - 1];
    }
  }
  for (int i = 1; i <= q; i++) {
    int k;
    scanf("%s%d", s + 1, &k);
    int b = 1, res = 0;
    for (int j = n; j >= 1; j--) {
      if (s[j] == '1') res += b;
      b *= 2;
    }
    printf("%d\n", dp[res][k]);
  }
}
