PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000393. Nghịch đảo Dirichlet và tổng tiền tố (Dirichlet Inverse and Prefix Sums)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nghịch đảo Dirichlet và tổng tiền tố (Dirichlet Inverse and Prefix Sums)

Dirichlet Inverse and Prefix Sums

Source: Library Checker

Version: Phuoc Hung OJ Extended

Problem Statement

Define QN={⌊N/i⌋:1≤i≤N}Q_N=\{\lfloor N/i\rfloor:1\le i\le N\} and let its distinct elements in increasing order be a0<⋯<ak−1a_0<\cdots<a_{k-1}.

For a sequence ff only its prefix sums F(x)=∑i=1xf(i)(mod998244353)F(x)=\sum_{i=1}^x f(i)\pmod{998244353} at x∈QNx\in Q_N are given. We guarantee f(1)=F(1)≠0f(1)=F(1)\ne0.

Its inverse under Dirichlet convolution is the sequence gg satisfying

∑uv=nf(u)g(v)=δn,1.\sum_{uv=n}f(u)g(v)=\delta_{n,1}.

Compute the prefix sums G(x)=∑j=1xg(j)G(x)=\sum_{j=1}^xg(j) at all x∈QNx\in Q_N, modulo 998244353998244353.

Input

A line containing 1, then NN, then the kk values F(aj)F(a_j). PHOJ uses one case per file.

Full bound: N≤1012N\le10^{12}, matching the original Library Checker bound. The reference implementation uses a faster quotient-table algorithm.

Output

The kk values G(a0),…,G(ak−1)G(a_0),\ldots,G(a_{k-1}), modulo 998244353998244353.

Subtasks

  • Subtask 1 (20 points): 1≤N≤1001\le N\le100, 0≤F(aj)<9982443530\le F(a_j)<998244353, F(1)≠0F(1)\ne0, T=1T=1.

  • Subtask 2 (30 points): 1≤N≤1061\le N\le10^6, 0≤F(aj)<9982443530\le F(a_j)<998244353, F(1)≠0F(1)\ne0, T=1T=1.

  • Subtask 3 (50 points): 1≤N≤10121\le N\le10^{12}, 0≤F(aj)<9982443530\le F(a_j)<998244353, F(1)≠0F(1)\ne0, T=1T=1.

Examples

Input

1
10
1 2 3 5 10

Output

1 0 998244352 998244351 998244352

Explanation

f(n)=1f(n)=1 has prefix F(x)=xF(x)=x. Its Dirichlet inverse is the Möbius function. The sums at 1,2,3,5,101,2,3,5,10 are 1,0,−1,−2,−11,0,-1,-2,-1 respectively, giving the displayed modular residues.