#include <bits/stdc++.h>
using namespace std;
const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 998244353;
int a, b, q;
int ar[maxn];
int num[maxn];
int s[1 << 13][120];
int main() {
  scanf("%d %d %d", &a, &b, &q);
  for (int i = 0; i < a; i++) scanf(" %d", &ar[i]);
  for (int i = 1; i <= b; i++) {
    char X[20];
    scanf(" %s", X);
    int x = 0;
    for (int j = 0; j < a; j++)
      if (X[j] == '1') x += 1 << j;
    num[x]++;
  }
  int h = 1 << a;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < h; j++) {
      int cos = 0;
      for (int k = 0; k < a; k++)
        if (!((i ^ j) & (1 << k))) cos += ar[k];
      if (cos <= 100) s[i][cos] += num[j];
    }
    for (int j = 1; j <= 100; j++) s[i][j] += s[i][j - 1];
  }
  for (int i = 1; i <= q; i++) {
    char X[20];
    int c;
    scanf(" %s %d", X, &c);
    int x = 0;
    for (int j = 0; j < a; j++)
      if (X[j] == '1') x += 1 << j;
    printf("%d\n", s[x][c]);
  }
  return 0;
}
