#include using namespace std; #include #include using namespace atcoder; using mint = modint998244353; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int p; cin >> p; vector a(p), b(p); for (int i = 1; i < p; i++) { cin >> a[i]; } for (int i = 1; i < p; i++) { cin >> b[i]; } if (p == 2) { cout << (mint(a[1]) * b[1]).val() << "\n"; return 0; } // prime factorization of p - 1 vector pf; { int tmp = p - 1; for (int i = 2; i * i <= tmp; i++) { if (tmp % i == 0) { pf.push_back(i); while (tmp % i == 0) { tmp /= i; } } } if (tmp > 1) { pf.push_back(tmp); } } auto pow_mod = [&](int x, int n) { int res = 1; while (n > 0) { if (n & 1) { res = (long long)res * x % p; } x = (long long)x * x % p; n >>= 1; } return res; }; // find a primitive root int pr = 2; random_device rd; mt19937 mt(rd()); uniform_int_distribution dist(2, p - 1); while (true) { pr = dist(mt); bool ok = true; for (int i : pf) { if (pow_mod(pr, (p - 1) / i) == 1) { ok = false; break; } } if (ok) { break; } } assert(pr > 1); vector gr(p), logp(p); int cur = 1; for (int i = 0; i < p - 1; i++) { gr[cur] = i; logp[i] = cur; cur = (long long)cur * pr % p; } vector f(p - 1), g(p - 1); for (int i = 1; i < p; i++) { f[gr[i]] = a[i]; g[gr[i]] = b[i]; } auto h = convolution(f, g); vector ans(p); for (int i = 0; i < h.size(); i++) { ans[logp[i % (p - 1)]] += h[i]; } for (int i = 1; i < p; i++) { cout << ans[i].val() << " "; } cout << "\n"; }