#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } struct FastFourierTransform{ using real = long double; using C=complex; const real PI=acosl(-1); int base; vector rts; vector rev; FastFourierTransform(int sz=1):base(1){ rts.emplace_back(0,0); rts.emplace_back(1,0); rev.push_back(0); rev.push_back(1); ensure_base(sz); } void ensure_base(int nbase){ if(nbase<=base) return; rev.resize(1<>1]>>1)+((i&1)<<(nbase-1)); } while(base &a, int n){ assert((n&(n-1))==0); int zeros = __builtin_ctz(n); ensure_base(zeros); int shift=base-zeros; for(int i=0;i>shift)) swap(a[i],a[rev[i]>>shift]); for(int k=1;k multiply(const vector &a, const vector &b) { int need=(int)a.size()+(int)b.size()-1; int nbase=1; while((1< fa(sz); for(int i=0;i>1)),s(0,1),t(0.5,0); for(int i=0;i<=(sz>>1);i++){ int j=(sz-i)&(sz-1); C z=(fa[j]*fa[j]-conj(fa[i]*fa[i]))*r; fa[j]=(fa[i]*fa[i]-conj(fa[j]*fa[j]))*r; fa[i]=z; } for(int i=0;i<(sz>>1);i++){ C A0=(fa[i]+fa[i+(sz>>1)])*t; C A1=(fa[i]-fa[i+(sz>>1)])*t*rts[(sz>>1)+i]; fa[i]=A0+A1*s; } fft(fa,sz>>1); vector ret(need); for(int i=0;i>1].imag():fa[i>>1].real()); return ret; } }; signed main(){ int N,M,S; cin>>N>>M>>S; vector A(S+1),B(S+1); rep(i,N){ int p;cin>>p; A[p]++; } rep(j,M){ int p;cin>>p; B[p]++; } reverse(ALL(B)); FastFourierTransform F; auto C=F.multiply(A,B); int Q;cin>>Q; rep(i,Q) cout<