#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 4100;
int n, m, q;
int w[15];
int flag[N];
int ans[N][105];
char s[15];
int zhuanhuan(char a[]) {
  int len = strlen(a);
  int sum = 0;
  int x = 1;
  for (int i = len - 1; i >= 0; --i) {
    if (a[i] == '1') {
      sum += x;
    }
    x = x * 2;
  }
  return sum;
}
int main() {
  while (~scanf("%d %d %d", &n, &m, &q)) {
    for (int i = 0; i < n; ++i) {
      scanf("%d", &w[i]);
    }
    memset(flag, 0, sizeof(flag));
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < m; ++i) {
      scanf("%s", s);
      flag[zhuanhuan(s)]++;
    }
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (flag[j] != 0) {
          int sum = 0;
          int p = i ^ j;
          for (int k = 0; k < n; ++k) {
            if ((p & 1) == 0) {
              sum += w[n - k - 1];
            }
            p >>= 1;
          }
          for (int k = sum; k <= 100; ++k) {
            ans[i][k] += flag[j];
          }
        }
      }
    }
    for (int i = 0; i < 30000; ++i) {
    }
    for (int i = 0; i < q; ++i) {
      char tmp[15];
      int k;
      scanf("%s %d", tmp, &k);
      printf("%d\n", ans[zhuanhuan(tmp)][k]);
    }
  }
  return 0;
}
