#include #include #include #include #include using namespace std; typedef long long LL; LL ww[101]; LL* e = ww + 50; const int MAXN = 4e5 + 5; LL P = 998244353; LL qpow(LL a, LL k, LL p) { LL c = 1; while (k) { if (k & 1) c = (c * a) % p; k >>= 1; a = (a * a) % p; } return c; } void primeroot(LL* e, const LL& P, const LL& g) { int s = 0; LL q = P - 1; while ((q & 1) == 0) {s++; q >>= 1;} LL w = qpow(g, q, P); LL invw = qpow(w, P - 2, P); for (int h = s; h >= 0; h--) { e[h] = w; e[-h] = invw; w = (w * w) % P; invw = (invw * invw) % P; } } void ntt(LL* f, const int& h, const int& type) { if (h == 0) return; LL f0[1 << (h - 1)], f1[1 << (h - 1)]; int n = 1 << h; for (int i = 0; i < n; i+=2) f0[i/2] = f[i]; ntt(f0, h - 1, type); for (int i = 1; i < n; i+=2) f1[i/2] = f[i]; ntt(f1, h - 1, type); LL w = e[type * h]; LL x = 1; for (int k = 0; k < n / 2; k++) { f[k] = f0[k] + x * f1[k]; f[k] %= P; f[k + n / 2] = f0[k] - x * f1[k]; f[k + n / 2] %= P; x *= w; x %= P; } } LL a[MAXN], b[MAXN], c[MAXN]; int main() { primeroot(e, P, 3); int n, m,l, t,q; scanf("%d%d%d", &l, &m, &n); for (int i = 0; i < l; i++) {scanf("%d", &t);a[t]=1;} for (int i = 0; i < m; i++) {scanf("%d", &t);b[n-t]=1;} scanf("%d", &q); int deg = 1, h = 0; while (deg < 2*n) {deg <<= 1; h++;} // printf("a:");for (int i = 0; i < deg; i++)printf(" %lld",a[i]);printf("\n"); // printf("b:");for (int i = 0; i < deg; i++)printf(" %lld",b[i]);printf("\n"); ntt(a, h, 1); ntt(b, h, 1); for (int i = 0; i < deg; i++) c[i] = a[i] * b[i] % P; ntt(c, h, -1); LL inv = qpow(deg, P - 2, P); for (int i = 0; i < deg; i++) { c[i] = (c[i] * inv) % P; c[i] = (c[i] + P) % P; } // printf("c:");for (int i = 0; i < deg; i++)printf(" %lld",c[i]);printf("\n"); for(int v=0;v