#include #include using namespace std; using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; using mint = modint998244353; const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int calc_primitive_root(int p) { if (p == 2) return 1; if (p == 167772161) return 3; if (p == 469762049) return 3; if (p == 754974721) return 11; if (p == 998244353) return 3; // p-1 の素因数分解 int divs[20] = {}; divs[0] = 2; int cnt = 1; long long x = (p - 1) / 2; while (x % 2 == 0) x /= 2; for (long long i = 3; i * i <= x; i += 2) { if (x % i == 0) { divs[cnt++] = i; while (x % i == 0) x /= i; } } if (x > 1) divs[cnt++] = x; // 原始根であるかの判定のために root^((p-1)/d) != 1 (mod p) を確かめる for (int root = 2;; ++root) { bool ok = true; for (int i = 0; i < cnt; ++i) { if (pow_mod(root, (p - 1) / divs[i], p) == 1) { ok = false; break; } } if (ok) return root; } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); mapmp; int p; cin >> p; int root = calc_primitive_root(p); rep(i, p - 1) { int x = pow_mod(root, i, p); mp[x] = i; } vectora(p), b(p); rep(i, p - 1) { int x; cin >> x; a[mp[i + 1]] += x; } rep(i, p - 1) { int x; cin >> x; b[mp[i + 1]] += x; } auto c = convolution(a, b); vectorans(p); rep(i, c.size()) { int x = pow_mod(root, i, p); ans[x] += c[i]; } rep2(i, 1, ans.size())cout << ans[i].val() << " "; cout << endl; return 0; }