#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
const long long inf = (long long)1e16;
const long double eps = 1e-12;
const long long N = (int)1e5 + 5;
const long long LOGN = 19;
const long double PI = 3.14159265358979323846;
inline long long mul(long long a, long long b, long long m = mod) {
  return (long long)(a * b) % m;
}
inline long long add(long long a, long long b, long long m = mod) {
  a += b;
  if (a >= m) a -= m;
  if (a < 0) a += m;
  return a;
}
inline long long power(long long a, long long b, long long m = mod) {
  if (b == 0) return 1;
  if (b == 1) return (a % m);
  long long x = power(a, b / 2, m);
  x = mul(x, x, m);
  if (b % 2) x = mul(x, a, m);
  return x;
}
vector<string> all_perms;
map<string, int> mp;
map<string, int> ind;
int w[15];
int dp[4200][105];
void rec(string& curr, int rem) {
  if (rem == 0) {
    all_perms.push_back(curr);
    return;
  }
  string go = curr + '0';
  rec(go, rem - 1);
  go = curr + '1';
  rec(go, rem - 1);
}
inline void gen(int n) {
  string pass;
  rec(pass, n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (0) {
    freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r",
            stdin);
    freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w",
            stdout);
  }
  int n, m, q;
  cin >> n >> m >> q;
  gen(n);
  for (int i = 0; i < n; i++) cin >> w[i];
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int k = all_perms.size();
  for (int i = 0; i < k; i++) {
    string s = all_perms[i];
    ind[s] = i;
    vector<pair<int, int> > put;
    for (auto it : mp) {
      int val = 0;
      string t = it.first;
      assert(s.length() == t.length());
      for (int j = 0; j < s.length(); j++)
        if (s[j] == t[j]) val += w[j];
      put.push_back({val, it.second});
    }
    for (auto it : put) {
      if (it.first <= 102) dp[i][it.first] += it.second;
    }
    for (int j = 1; j <= 101; j++) dp[i][j] += dp[i][j - 1];
  }
  while (q--) {
    string s;
    int c;
    cin >> s >> c;
    printf("%d\n", dp[ind[s]][c]);
  }
  return 0;
}
