#include<bits/stdc++.h>
using namespace std;
int w[15],g[4100],h[4100];
int n,m,q;
int arr[4100][110];
int main(){
cin>>n>>m>>q;
for(int i=n-1;i>=0;i--){
cin>>w[i];
}
for(int i=0;i<(1<<n);i++){
for(int j=0;j<n;j++){
if((i>>j)&1){
g[i]+=w[j];
}
}
}
for(int i=1;i<=m;i++){
string s;
cin>>s;
int t=0;
for(int j=0;j<n;j++){
t=t*2+s[j]-'0';
}
h[t]++;
}
for(int i=0;i<(1<<n);i++){
for(int j=0;j<(1<<n);j++){
int t=i^j^((1<<n)-1);
if(g[t]<=100){
arr[i][g[t]]+=h[j];
}
}
}
for(int i=0;i<(1<<n);i++){
for(int j=1;j<=100;j++){
arr[i][j]+=arr[i][j-1];
}
}
for(int i=1;i<=q;i++){
string s;
int k;
cin>>s>>k;
int t=0;
for(int j=0;j<n;j++){
t=t*2+s[j]-'0';
}
cout<<arr[t][k]<<endl;
}
return 0;
}