#include <bits/stdc++.h>
using namespace std;
const int md = 998244353;
int add(int x, int y) {
x += y;
if (x >= md) {
x -= md;
}
return x;
}
int sub(int x, int y) {
x -= y;
if (x < 0) {
x += md;
}
return x;
}
int mul(int x, int y) {
return (long long)x * y % md;
}
int power(int x, int y) {
int result = 1;
for (; y; y >>= 1, x = mul(x, x)) {
if (y & 1) {
result = mul(result, x);
}
}
return result;
}
namespace ntt {
int base = 1, root = -1, max_base = -1;
vector<int> roots = {0, 1}, rev = {0, 1};
void init() {
int temp = md - 1;
max_base = 0;
while (!(temp & 1)) {
temp >>= 1;
++max_base;
}
root = 2;
while (true) {
if (power(root, 1 << max_base) == 1 && power(root, 1 << max_base - 1) != 1) {
break;
}
++root;
}
}
void ensure_base(int nbase) {
if (max_base == -1) {
init();
}
if (nbase <= base) {
return;
}
assert(nbase <= max_base);
rev.resize(1 << nbase);
for (int i = 0; i < (1 << nbase); ++i) {
rev[i] = rev[i >> 1] >> 1 | ((i & 1) << nbase - 1);
}
roots.resize(1 << nbase);
while (base < nbase) {
int z = power(root, 1 << max_base - 1 - base);
for (int i = 1 << base - 1; i < 1 << base; ++i) {
roots[i << 1] = roots[i];
roots[i << 1 | 1] = mul(roots[i], z);
}
++base;
}
}
void dft(vector<int> &a) {
int n = a.size(), zeros = __builtin_ctz(n);
ensure_base(zeros);
int shift = base - zeros;
for (int i = 0; i < n; ++i) {
if (i < rev[i] >> shift) {
swap(a[i], a[rev[i] >> shift]);
}
}
for (int i = 1; i < n; i <<= 1) {
for (int j = 0; j < n; j += i << 1) {
for (int k = 0; k < i; ++k) {
int x = a[j + k], y = mul(a[j + k + i], roots[i + k]);
a[j + k] = add(x, y);
a[j + k + i] = sub(x, y);
}
}
}
}
vector<int> padd(vector<int> a, vector<int> b) {
if (a.size() < b.size()) {
a.resize(b.size());
}
for (int i = 0; i < b.size(); ++i) {
a[i] = add(a[i], b[i]);
}
return a;
}
vector<int> psub(vector<int> a, vector<int> b) {
if (a.size() < b.size()) {
a.resize(b.size());
}
for (int i = 0; i < b.size(); ++i) {
a[i] = sub(a[i], b[i]);
}
return a;
}
vector<int> pmul(vector<int> a, vector<int> b, bool equal = false) {
int need = a.size() + b.size() - 1, nbase = 0;
while (1 << nbase < need) {
++nbase;
}
ensure_base(nbase);
int size = 1 << nbase;
a.resize(size);
b.resize(size);
dft(a);
if (equal) {
b = a;
} else {
dft(b);
}
int inv = power(size, md - 2);
for (int i = 0; i < size; ++i) {
a[i] = mul(mul(a[i], b[i]), inv);
}
reverse(a.begin() + 1, a.end());
dft(a);
a.resize(need);
return a;
}
vector<int> psqr(vector<int> a) {
return pmul(a, a, true);
}
vector<int> pinv(vector<int> a) {
int n = a.size(), m = n + 1 >> 1;
if (n == 1) {
return vector<int> (1, power(a[0], md - 2));
} else {
vector<int> b = pinv(vector<int> (a.begin(), a.begin() + m));
int need = n << 1, nbase = 0;
while (1 << nbase < need) {
++nbase;
}
ensure_base(nbase);
int size = 1 << nbase;
a.resize(size);
b.resize(size);
dft(a);
dft(b);
int inv = power(size, md - 2);
for (int i = 0; i < size; ++i) {
a[i] = mul(mul(sub(2, mul(a[i], b[i])), b[i]), inv);
}
reverse(a.begin() + 1, a.end());
dft(a);
a.resize(n);
return a;
}
}
vector<int> pdiv(vector<int> a, vector<int> b) {
int n = a.size(), m = b.size();
if (n < m) {
return vector<int> ();
}
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
b.resize(n - m + 1);
b = pmul(a, pinv(b));
b.erase(b.begin() + n - m + 1, b.end());
reverse(b.begin(), b.end());
return b;
}
vector<int> pmod(vector<int> a, vector<int> b) {
int n = a.size(), m = b.size();
if (n < m) {
return a;
}
vector<int> c = pmul(pdiv(a, b), b);
for (int i = 0; i < m - 1; ++i) {
c[i] = sub(a[i], c[i]);
}
c.resize(m - 1);
return c;
}
}
using ntt::padd;
using ntt::psub;
using ntt::pmul;
using ntt::psqr;
using ntt::pinv;
using ntt::pdiv;
using ntt::pmod;
int main() {
#ifdef wxh010910
freopen("input.txt", "r", stdin);
#endif
int n;
scanf("%d", &n);
vector<int> a(n), b(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
for (int i = 0; i < n; ++i) {
scanf("%d", &b[i]);
}
function<vector<int>(int, int)> multiply_all = [&](int l, int r) {
if (l == r) {
return vector<int> {1, sub(0, a[l])};
} else {
int mid = l + r >> 1;
return pmul(multiply_all(l, mid), multiply_all(mid + 1, r));
}
};
vector<vector<int>> segtree((n << 1) - 1);
function<void(int, int, int)> build = [&](int x, int l, int r) {
if (l == r) {
segtree[x] = vector<int> {sub(0, power(a[l], md - 2)), 1};
} else {
int y = l + r >> 1, z = x + (y - l + 1 << 1);
build(x + 1, l, y);
build(z, y + 1, r);
segtree[x] = pmul(segtree[x + 1], segtree[z]);
}
};
function<void(int, int, int, vector<int>, vector<int>&)> evaluate = [&](int x, int l, int r, vector<int> f, vector<int> &answer) {
f = pmod(f, segtree[x]);
if (l == r) {
answer[l] = f[0];
} else {
int y = l + r >> 1, z = x + (y - l + 1 << 1);
evaluate(x + 1, l, y, f, answer);
evaluate(z, y + 1, r, f, answer);
}
};
vector<int> f = pmul(b, multiply_all(0, n - 1)), p(n), q(n);
f.resize(n);
build(0, 0, n - 1);
evaluate(0, 0, n - 1, f, p);
int coef = 1;
for (int i = 0; i < n; ++i) {
coef = mul(coef, sub(0, a[i]));
}
for (int i = 0; i < n; ++i) {
f[i] = mul(mul(n - i, segtree[0][i]), coef);
}
evaluate(0, 0, n - 1, f, q);
for (int i = 0; i < n; ++i) {
printf("%d%c", mul(p[i], power(q[i], md - 2)), i == n - 1 ? '\n' : ' ');
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG1kID0gOTk4MjQ0MzUzOwoKaW50IGFkZChpbnQgeCwgaW50IHkpIHsKICB4ICs9IHk7CiAgaWYgKHggPj0gbWQpIHsKICAgIHggLT0gbWQ7CiAgfQogIHJldH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KICBmb3IgKGludCBpID0gMDsgaSA8ICgxIDw8IG5iYXNlKTsgKytpKSB7CiAgICByZXZbaV0gPSByZXZbaSA+PiAxXSA+PiAxIHwgKChpICYgMSkgPDwgbmJhc2UgLSAxKTsKICB9CiAgcm9vdHMucmVzaXplKDEgPDwgbmJhc2UpOwogIHdoaWxlIChiYXNlIDwgbmJhc2UpIHsKICAgIGludCB6ID0gcG93ZXIocm9vdCwgMSA8PCBtYXhfYmFzZSAtIDEgLSBiYXNlKTsKICAgIGZvciAoaW50IGkgPSAxIDw8IGJhc2UgLSAxOyBpIDwgMSA8PCBiYXNlOyArK2kpIHsKICAgICAgcm9vdHNbaSA8PCAxXSA9IHJvb3RzW2ldOwogICAgICByb290c1tpIDw8IDEgfCAxXSA9IG11bChyb290c1tpXSwgeik7CiAgICB9CiAgICArK2Jhc2U7CiAgfQp9Cgp2b2lkIGRmdCh2ZWN0b3I8aW50PiAmYSkgewogIGludCBuID0gYS5zaXplKCksIHplcm9zID0gX19idWlsdGluX2N0eihuKTsKICBlbnN1cmVfYmFzZSh6ZXJvcyk7CiAgaW50IHNoaWZ0ID0gYmFzZSAtIHplcm9zOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgKytpKSB7CiAgICBpZiAoaSA8IHJldltpXSA+PiBzaGlmdCkgewogICAgICBzd2FwKGFbaV0sIGFbcmV2W2ldID4+IHNoaWZ0XSk7CiAgICB9CiAgfQogIGZvciAoaW50IGkgPSAxOyBpIDwgbjsgaSA8PD0gMSkgewogICAgZm9yIChpbnQgaiA9IDA7IGogPCBuOyBqICs9IGkgPDwgMSkgewogICAgICBmb3IgKGludCBrID0gMDsgayA8IGk7ICsraykgewogICAgICAgIGludCB4ID0gYVtqICsga10sIHkgPSBtdWwoYVtqICsgayArIGldLCByb290c1tpICsga10pOwogICAgICAgIGFbaiArIGtdID0gYWRkKHgsIHkpOwogICAgICAgIGFbaiArIGsgKyBpXSA9IHN1Yih4LCB5KTsKICAgICAgfQogICAgfQogIH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