#P5394. Polynomial Multiplication under Modulo 998244353

    ID: 18626 Type: Default 1000ms 256MiB

Polynomial Multiplication under Modulo 998244353

Polynomial Multiplication under Modulo 998244353

Given two polynomials in descending power order, namely a polynomial \( A(x) \) of degree \( n \) and a polynomial \( B(x) \) of degree \( m \), compute the polynomial \( F(x) \) of degree \( n+m \) such that

\( F(x) = A(x) \times B(x) \).

Note that the coefficients of \( F(x) \) can be very large, so you are required to take every coefficient modulo \( 998244353 \).

inputFormat

The first line contains two integers \( n \) and \( m \) indicating the degrees of the two polynomials.

The second line contains \( n+1 \) space-separated integers representing the coefficients of \( A(x) \) in descending order, i.e., from the coefficient of \( x^n \) to \( x^0 \).

The third line contains \( m+1 \) space-separated integers representing the coefficients of \( B(x) \) in descending order, i.e., from the coefficient of \( x^m \) to \( x^0 \).

outputFormat

Output a single line containing \( n+m+1 \) space-separated integers representing the coefficients of \( F(x) \) in descending order (from \( x^{n+m} \) to \( x^0 \)), with each coefficient taken modulo \( 998244353 \).

sample

1 1
1 2
3 4
3 10 8