#include #include #include #define llint long long #define PI 3.141592653589793238 using namespace std; typedef complex Complex; void DFT(vector &f, int n, vector &F) { F.resize(n); if(n == 1){ F[0] = f[0]; return; } vector f0(n/2), f1(n/2), F0, F1; for(int i = 0; i < n/2; i++) f0[i] = f[i*2]; DFT(f0, n/2, F0); for(int i = 0; i < n/2; i++) f1[i] = f[i*2+1]; DFT(f1, n/2, F1); Complex z = Complex(cos(2*PI/n), sin(2*PI/n)), x = Complex(1, 0); for(int i = 0; i < n; i++){ F[i] = F0[i%(n/2)] + x * F1[i%(n/2)]; x *= z; } } //The answer must be divided by n. void IDFT(vector &f, int n, vector &F) { F.resize(n); if(n == 1){ F[0] = f[0]; return; } vector f0(n/2), f1(n/2), F0, F1; for(int i = 0; i < n/2; i++) f0[i] = f[i*2]; IDFT(f0, n/2, F0); for(int i = 0; i < n/2; i++) f1[i] = f[i*2+1]; IDFT(f1, n/2, F1); Complex z = Complex(cos(2*PI/n), -sin(2*PI/n)), x = Complex(1, 0); for(int i = 0; i < n; i++){ F[i] = F0[i%(n/2)] + x * F1[i%(n/2)]; x *= z; } } llint round(Complex c){ return (int)(c.real()+0.5); } llint L, M, N, Q; llint A[100005], B[100005]; llint a[100005], b[100005]; const llint S = 1<<18; vector f(S), g(S), h, F, G, H(S); int main(void) { cin >> L >> M >> N; for(int i = 0; i < L; i++) cin >> A[i]; for(int i = 0; i < M; i++) cin >> B[i]; cin >> Q; for(int i = 0; i < L; i++) a[A[i]] = 1; for(int i = 0; i < M; i++) b[B[i]] = 1; for(int i = 1; i <= 100000; i++) f[100001-i] = a[i]; for(int i = 1; i <= 100000; i++) g[i] = b[i]; DFT(f, S, F), DFT(g, S, G); for(int i = 0; i < S; i++) H[i] = F[i]*G[i]; IDFT(H, S, h); for(int i = 0; i < S; i++) h[i] /= S; for(int i = 0; i < Q; i++) cout << round(h[100001-i]) << endl; return 0; }