Problem11301--[yosupo] Polynomial - Sqrt of Formal Power Series (Sparse)

11301: [yosupo] Polynomial - Sqrt of Formal Power Series (Sparse)

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB  Special Judge

Description

You are given a formal power series $f(x) = \sum_{i=0}^{N-1} a_i x^i \in \mathbb{F}\_{998244353}[[x]]$.
Only $K$ coefficients of $f$ are non-zero, and only such coefficients $a_{i_k}$ are given from input. 

Calculate the first $N$ terms of a square root of $f(x)$.
In other words, find $g(x) = \sum_{i=0}^{N-1} b_i x^i \in \mathbb{F}\_{998244353}[[x]]$ such that

$f(x) \equiv g(x)^2 \pmod{x^N}.$

Input

$N$ $K$
$i_0$ $a_{i_0}$
$\vdots$
$i_{K-1}$ $a_{i_{K-1}}$

Output

If there are no $g(x)$ satisfying the condition, print
-1
and if such $g(x)$ exists, choose any and print
$b_0$ $b_1$ $\cdots$ $b_{N - 1}$

Constraints

- $1 \leq N \leq 10^6$
- $0 \leq K \leq 10$
- $0 \leq i_0 < \cdots < i_{K-1} \leq N - 1$
- $1 \leq a_{i_k} < 998244353$

Sample 1 Input

4 2
2 9
3 12

Sample 1 Output

0 998244350 998244351 0

Sample 2 Input

4 2
2 10
3 12

Sample 2 Output

-1

Sample 3 Input

5 0

Sample 3 Output

0 0 0 0 0

HINT

Source/Category