#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x Comp; vector fft(vector v, bool rev=false) { int n=v.size(),i,j,m; for(i=0,j=1;j>1;k>(i^=k);k>>=1); if(i>j) swap(v[i],v[j]); } for(int m=2; m<=n; m*=2) { double deg=(rev?-1:1) * 2*acos(-1)/m; Comp wr(cos(deg),sin(deg)); for(i=0;i MultPoly(vector P,vector Q) { P=fft(P), Q=fft(Q); for(int i=0;i AC(1<<19,0),BC(1<<19,0); cin>>L>>M>>N; FOR(i,L) cin>>A[i], AC[A[i]]+=1; FOR(i,M) cin>>B[i], BC[N-B[i]]+=1; cin>>Q; auto CC=MultPoly(AC,BC); FOR(i,Q) _P("%d\n",(int)(CC[i+N].real()+0.1)); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }