#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
const int oo = 1e9;
const int mod = 1e9 + 7;
int w[15], f[10010], g[(1 << 12)][(1 << 12)], c[(1 << 12)][1410];
char s[15];
int main() {
  int n, m, q;
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < n; i++) scanf("%d", w + i);
  for (int i = 0; i < m; i++) {
    scanf("%s", s);
    int e = 0;
    for (int j = 0; j < n; j++) e += (s[j] - '0') * (1 << j);
    f[e]++;
  }
  for (int i = 0; i < (1 << n); i++)
    for (int j = 0; j < (1 << n); j++)
      for (int x = 0; x < n; x++)
        if ((i & (1 << x)) == (j & (1 << x))) g[i][j] += w[x];
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 0; j < (1 << n); j++) c[i][g[i][j]] += f[j];
    for (int j = 1; j <= 1300; j++) c[i][j] += c[i][j - 1];
  }
  for (int i = 0; i < q; i++) {
    int k;
    scanf("%s%d", s, &k);
    int e = 0;
    for (int j = 0; j < n; j++) e += (s[j] - '0') * (1 << j);
    printf("%d\n", c[e][k]);
  }
}
