#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ ) #define rep(i,n) REP(i,0,n) typedef long long ll; typedef pair pint; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=1e9+7 ; int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ; typedef vector> poly; const double pi=acos(-1); poly dft(poly f,int rev){ int n=f.size(); int j=0; REP(i,1,n-1){ for(int k=n/2;k>(j^=k);k>>=1); if(izeta=polar(1.0,pi/i*rev); for(int j=0;j ret=1; rep(k,i){ complex s=f[j+k]; complex t=f[j+k+i]; f[j+k]=s+t*ret; f[j+k+i]=s-t*ret; ret*=zeta; } } } if(rev==-1)rep(i,n)f[i]/=n; return f; } poly fft(poly g,poly h){ poly f; int m=(int)g.size()+h.size()+1; int sz=1; while(sz>l>>m>>n; poly a,b; a.resize(n+1); b.resize(n+1); rep(i,l){ int x; cin>>x; a[x]=1; } rep(i,m){ int x; cin>>x; b[n-x]=1; } poly c=fft(a,b); int q;cin>>q; rep(i,q)cout<<(int)(c[n+i].real()+0.5)<<"\n"; }