#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) ULL mpow(ULL a, ULL i, ULL M) { if (i == 0) return 1; ULL r = mpow(a * a % M, i >> 1, M); if (i & 1) r = r * a % M; return r; } void NTT(vector& A, ULL M, ULL g) { int N = A.size(); for (int i = 0, j = 0; j < N; j++) { if (i < j) swap(A[i], A[j]); for (int k = N >> 1; k > (i ^= k); k >>= 1); } for (int i = 1; i < N; i <<= 1) { ULL q = mpow(g, (M - 1) / i / 2, M), qj = 1; rep(j, i) { for (int k = j; k < N; k += i * 2) { ULL l = A[k], r = A[k + i] * qj % M; A[k] = (l + r); if (A[k] >= M) A[k] -= M; A[k + i] = (l + M - r); if (A[k + i] >= M) A[k + i] -= M; } qj = qj * q % M; } } } struct Fuse { ULL M, G; }; vector TNT(const vector& A, const vector& B, Fuse F) { int Z = 1; while (Z < A.size() + B.size()) Z <<= 1; vector Ax(Z), Bx(Z); ULL iZ = mpow(Z, F.M - 2, F.M); rep(i, Z) Ax[i] = Bx[i] = 0; rep(i, A.size()) Ax[i] = A[i]; rep(i, B.size()) Bx[i] = B[i]; NTT(Ax, F.M, F.G); NTT(Bx, F.M, F.G); rep(i, Z) Ax[i] = Ax[i] * Bx[i] % F.M; NTT(Ax, F.M, mpow(F.G, F.M - 2, F.M)); rep(i, Z) Ax[i] = Ax[i] * iZ % F.M; return move(Ax); } const Fuse fuse = { 998244353,3 }; ULL primroot(ULL M) { for (int g = 2; g < M - 2; g++) { bool ok = true; ULL p = 1; rep(i, (M - 1) / 2) { p = p * g % M; if (p == 1) { ok = false; break; } } if (ok) return g; } } ULL P; ULL g; ULL PowPmodP[100000]; ULL iPowPmodP[100000]; vector A, B; vector C; int main() { cin >> P; g = primroot(P); for (ULL i = 0, p = 1; i < P; i++, p = p * g % P) PowPmodP[i] = p; rep(i, P - 1) iPowPmodP[PowPmodP[i]] = i; A.resize(P - 1); rep(i, P - 1) { ULL a; cin >> a; A[iPowPmodP[i + 1]] = a; } B.resize(P - 1); rep(i, P - 1) { ULL a; cin >> a; B[iPowPmodP[i + 1]] = a; } C = TNT(A, B, fuse); rep(i, P - 1) C[i] = (C[i] + C[i + P - 1]) % 998244353; rep(i, P - 1) { if (i) cout << " "; cout << C[iPowPmodP[i + 1]]; } cout << endl; return 0; }