#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
int n, m, q;
int w[14];
int sum[1 << 14][102];
int cnt[1 << 14];
int cnt2[1 << 14];
vector<string> ss;
vector<pair<string, int>> st;
void dfs(int x, int cur, int y, int ws) {
  if (cur == n) {
    if (ws <= 100) sum[x][ws] += cnt[y];
    return;
  }
  if ((1 << cur) & x) {
    dfs(x, cur + 1, y + (1 << cur), ws + w[n - 1 - cur]);
    dfs(x, cur + 1, y, ws);
  } else {
    dfs(x, cur + 1, y + (1 << cur), ws);
    dfs(x, cur + 1, y, ws + w[n - 1 - cur]);
  }
}
int main() {
  cin >> n >> m >> q;
  char str[20];
  for (int i = 0; i < n; ++i) {
    scanf("%d", &w[i]);
  }
  memset(cnt, 0, sizeof(cnt));
  memset(cnt2, 0, sizeof(cnt2));
  memset(sum, 0, sizeof(sum));
  ss.clear();
  for (int i = 0; i < m; ++i) {
    scanf("%s", str);
    ss.push_back(string(str));
    int x = 0;
    for (int j = 0; j < n; ++j) {
      x = x * 2 + str[j] - '0';
    }
    cnt[x]++;
  }
  st.clear();
  for (int i = 0; i < q; ++i) {
    int k;
    scanf("%s%d", str, &k);
    st.push_back(make_pair(string(str), k));
    int x = 0;
    for (int j = 0; j < n; ++j) {
      x = x * 2 + str[j] - '0';
    }
    cnt2[x]++;
  }
  for (int i = 0; i < (1 << n); ++i) {
    if (!cnt2[i]) continue;
    dfs(i, 0, 0, 0);
    for (int j = 1; j <= 100; ++j) {
      sum[i][j] += sum[i][j - 1];
    }
  }
  for (int i = 0; i < q; ++i) {
    string s = st[i].first;
    int k = st[i].second;
    int x = 0;
    for (int j = 0; j < n; ++j) {
      x = x * 2 + s[j] - '0';
    }
    printf("%d\n", sum[x][k]);
  }
  return 0;
}
