#include #define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++) #define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--) #define rep(i, n) FOR(i, 0, n) #define ALL(x) (x).begin(), (x).end() using namespace std; using ll = long long; template using V = vector; constexpr int Mod = 998244353; constexpr int mod = 1e9 + 7; constexpr ll inf = 1LL << 60; template constexpr bool chmax(T &a, const T &b) { if(a >= b) return false; a = b; return true; } template constexpr bool chmin(T &a, const T &b) { if(a <= b) return false; a = b; return true; } /*-------------------------------------------*/ class mycomplex { double r, i; public: constexpr mycomplex(const double &r = 0, const double &i = 0) : r(r), i(i) {} constexpr mycomplex(const complex &c) : r(c.real()), i(c.imag()) {} constexpr double real() const { return r; } constexpr double imag() const { return i; } constexpr double abs() const { return hypot(r, i); } constexpr mycomplex &operator+=(const mycomplex &c) { r += c.r; i += c.i; return *this; } constexpr mycomplex &operator-=(const mycomplex &c) { r -= c.r; i -= c.i; return *this; } constexpr mycomplex &operator*=(const mycomplex &c) { double x = r; r = r * c.r - i * c.i; i = x * c.i + i * c.r; return *this; } constexpr mycomplex &operator/=(const mycomplex &c) { *this *= mycomplex(c.r, c.i); double dnm = c.r * c.r - c.i * c.i; r /= dnm; i /= dnm; return *this; } template constexpr mycomplex &operator+=(const T &c) { return operator+=(mycomplex(c)); } template constexpr mycomplex operator+(const T &c) const { return mycomplex(*this) += c; } template constexpr mycomplex &operator-=(const T &c) { return operator-=(mycomplex(c)); } template constexpr mycomplex operator-(const T &c) const { return mycomplex(*this) -= c; } template constexpr mycomplex &operator*=(const T &c) { return operator*=(mycomplex(c)); } template constexpr mycomplex operator*(const T &c) const { return mycomplex(*this) *= c; } template constexpr mycomplex &operator/=(const T &c) { return operator/=(mycomplex(c)); } template constexpr mycomplex operator/(const T &c) const { return mycomplex(*this) /= c; } }; class FastFourierTransform { static void dft(V &func, const int &inverse) { int sz = func.size(); if(sz == 1) return; V va, vb; rep(i, sz / 2) { va.push_back(func[2 * i]); vb.push_back(func[2 * i + 1]); } dft(va, inverse); dft(vb, inverse); mycomplex now(1); mycomplex zeta(polar(1.0, inverse * 2.0 * acos(-1) / sz)); rep(i, sz) { func[i] = va[i & (sz >> 1) - 1] + now * vb[i & (sz >> 1) - 1]; now *= zeta; } } public: template static V multipli(const V &f, const V &g) { V nf, ng; int sz = 1; int n = f.size() + g.size(); while(sz < n) sz <<= 1; nf.resize(sz); ng.resize(sz); rep(i, f.size()) nf[i] = f[i]; rep(i, g.size()) ng[i] = g[i]; dft(nf, 1); dft(ng, 1); rep(i, sz) nf[i] *= ng[i]; dft(nf, -1); V res; for(const auto &z : nf) res.push_back(z.real() / sz); return res; } }; int main() { cin.tie(0); ios::sync_with_stdio(0); int l, m, n; cin >> l >> m >> n; V a(n + 1), b(n + 1); rep(i, l) { int x; cin >> x; a[x] = true; } rep(i, m) { int x; cin >> x; b[n - x] = true; } int q; cin >> q; V res = FastFourierTransform::multipli(a, b); rep(i, q) cout << int(res[i + n] + 0.1) << endl; return 0; }