#include using namespace std; template int least_bit(T n) { static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size"); if (sizeof(T) == 4) return __builtin_ffs(n) - 1; if (sizeof(T) == 8) return __builtin_ffsll(n) - 1; } template int most_bit(T n) { static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size"); if (sizeof(T) == 4) return n ? 31 - __builtin_clz(n) : -1; if (sizeof(T) == 8) return n ? 63 - __builtin_clzll(n) : -1; } template int count_bit(T n) { static_assert(sizeof(T) == 4 || sizeof(T) == 8, "unsupported size"); if (sizeof(T) == 4) return __builtin_popcount(n); if (sizeof(T) == 8) return __builtin_popcountll(n); } void fft(vector> &a, int n, int dir) { long double theta = dir * 2 * M_PIl / n; for (int m = n; m > 1; m /= 2) { int mh = m / 2; for (int i = 0; i < mh; i++) { auto w = exp(i * theta * complex(0, 1)); for (int j = i; j < n; j += m) { int k = j + mh; auto x = a[j] - a[k]; a[j] += a[k]; a[k] = w * x; } } theta *= 2; } int i = 0; for (int j = 1; j < n - 1; j++) { for (int k = n / 2; k > (i ^= k); k /= 2); if (j < i) swap(a[i], a[j]); } } template vector convolution(const vector &aa, const vector &bb){ vector> a(begin(aa), end(aa)), b(begin(bb), end(bb)); static_assert(sizeof(a.size() + b.size()) != 4, "???"); int n = 2 << most_bit(a.size() + b.size()); a.resize(n); b.resize(n); fft(a, n, 1); fft(b, n, 1); for (int i = 0; i < n; ++i) a[i] *= b[i]; fft(a, n, -1); vector res(n); for (int i = 0; i < n; ++i) res[i] = round(real(a[i]) / n); return res; } int main() { int l, m, n; cin >> l >> m >> n; vector a(n), b(n); for (int i = 0; i < l; ++i) { int k; cin >> k; ++a[k - 1]; } for (int i = 0; i < m; ++i) { int k; cin >> k; ++b[n - k]; } int q; cin >> q; auto c = convolution(a, b); for (int i = n - 1; i < n + q - 1; ++i) cout << c[i] << endl; }