#ifdef LOCAL111 #define _GLIBCXX_DEBUG #else #define NDEBUG #endif #define _USE_MATH_DEFINES #include const int INF = 1e9; using namespace std; template ostream& operator<< (ostream& os, const pair& p) { cout << '(' << p.first << ' ' << p.second << ')'; return os; } #define endl '\n' #define ALL(a) (a).begin(),(a).end() #define SZ(a) int((a).size()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #ifdef LOCAL111 #define DEBUG(x) cout<<#x<<": "<<(x)< void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} #else #define DEBUG(x) true template void dpite(T a, T b){ return; } #endif #define F first #define S second #define SNP string::npos #define WRC(hoge) cout << "Case #" << (hoge)+1 << ": " template void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;} template bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;} template bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;} typedef long long int LL; typedef unsigned long long ULL; typedef pair P; void ios_init(){ //cout.setf(ios::fixed); //cout.precision(12); #ifdef LOCAL111 return; #endif ios::sync_with_stdio(false); cin.tie(0); } class Polynomial { private: typedef double Real; typedef complex Complex; typedef vector::iterator iterator; typedef vector::const_iterator const_iterator; vector v; public: static const Real pi; Polynomial(int n){ v = vector(n); } Polynomial(vector x){ v = x; } Polynomial(){ } iterator begin(){return v.begin();} const_iterator begin() const {return v.begin();} iterator end(){return v.end();} const_iterator end() const {return v.end();} void push_back(Complex x) {v.push_back(x);} int size(){ return v.size(); } Complex& operator[](int i){ return v[i]; } const Complex& operator[](int i) const { return v[i]; } Polynomial dft(int n){ Polynomial res(n); for(int i = 0; i < (int)v.size(); ++i) { res[i] = v[i]; } for(int i = v.size(); i < n; ++i) { res[i] = 0; } function rec = [&](Polynomial p) -> Polynomial{ int n = p.size(); if(n == 1) return p; Polynomial f0(n/2); Polynomial f1(n/2); for(int i = 0; i < n; ++i) { if(i&1){ f1[i/2] = p[i]; }else{ f0[i/2] = p[i]; } } auto res0 = rec(f0); auto res1 = rec(f1); Complex theta = Complex(cos(2*pi/n),sin(2*pi/n)); Complex tmp = 1; Polynomial res(n); for(int i = 0; i < n; ++i) { int p = i; if(p >= n/2) p -= n/2; res[i] = res0[p]+res1[p]*tmp; tmp *= theta; } return res; }; res = rec(res); return res; } Polynomial inverse_dft(){ Polynomial res = *this; for(int i = 0; i < (int)res.size(); ++i) { res[i] = conj(res[i]); } int n = (int)v.size(); res = res.dft(n); for(int i = 0; i < (int)res.size(); ++i) { res[i] /= res.size(); } for(int i = 0; i < (int)res.size(); ++i) { res[i] = conj(res[i]); } return res; } Complex calc(Complex c){ Complex res = 0; Complex x = 1; for(int i = 0; i < (int)v.size(); ++i) { res += v[i]*x; x *= c; } return res; } Polynomial operator*(Polynomial y){ int m = y.size()+size(); int n = 1; while(n < m) { n <<= 1; } auto gg = dft(n); auto hh = y.dft(n); Polynomial res(n); for(int i = 0; i < n; ++i) { res[i] = gg[i]*hh[i]; } return res.inverse_dft(); } }; const Polynomial::Real Polynomial::pi(3.141592653589793238462643383279L); int main() { ios_init(); int l,m,n; while(cin >> l >> m >> n) { vector a(l),b(m); REP(i,l){ cin >> a[i]; a[i]--; } REP(i,m){ cin >> b[i]; b[i]--; } int q; cin >> q; Polynomial g(n),h(n); dpite(ALL(g)); dpite(ALL(h)); REP(i,l){ g[a[i]] = 1; } REP(i,m){ h[n-1-b[i]] = 1; } auto f = g*h; dpite(ALL(f)); FOR(i,n-1,n-1+q){ int ans = round(f[i].real()); cout << ans << endl; } } return 0; }