#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 2e9;
const long long INFLL = 1e18;
const int MAX_N = 13;
const int MAX_K = 5000;
const int MAX_W = 100;
int N, M, Q;
int w[MAX_N + 1];
vector<pair<int, int> > vt[MAX_K + 1];
int cnt[MAX_K + 1];
int dp[MAX_K + 1][MAX_W + 1];
char str[20];
int cost[MAX_K + 1];
int main() {
  scanf("%d%d%d", &N, &M, &Q);
  for (int i = 0; i < N; i++) {
    scanf("%d", &w[N - i - 1]);
  }
  for (int i = 0; i < (1 << N); i++) {
    for (int j = 0; j < N; j++) {
      if ((i & (1 << j))) {
        cost[i] += w[j];
      }
    }
  }
  for (int i = 0; i < M; i++) {
    scanf("%s", str);
    int t = 0;
    for (int k = 0; k < N; k++) {
      t *= 2;
      if (str[k] == '1') t++;
    }
    cnt[t]++;
  }
  for (int i = 0; i < (1 << N); i++) {
    if (cnt[i] == 0) continue;
    for (int j = 0; j < (1 << N); j++) {
      int sum, tmp;
      tmp = (1 << N) - 1 - (i ^ j);
      sum = cost[tmp];
      if (sum <= MAX_W) {
        dp[j][sum] += cnt[i];
      }
    }
  }
  for (int i = 0; i < (1 << N); i++) {
    for (int j = 1; j <= MAX_W; j++) {
      dp[i][j] += dp[i][j - 1];
    }
  }
  for (int i = 0; i < Q; i++) {
    int x = 0, y;
    scanf("%s %d", str, &y);
    for (int j = 0; j < N; j++) {
      x *= 2;
      if (str[j] == '1') x++;
    }
    printf("%d\n", dp[x][y]);
  }
  return 0;
}
