Problem G
Polynomial Multiplication 2


Standard input begins with an integer $T = 1$, the number of test cases (this is not a typo, there is always exactly one test case).

Each test case consists of two polynomials. A polynomial is given by an integer $1 \le n \le 131\, 071$ indicating the degree of the polynomial, followed by a sequence of integers $a_{0}, a_{1}, \ldots , a_{n}$, where $a_{i}$ is the coefficient of $x^{i}$ in the polynomial. All coefficients will fit in a signed 32-bit integer.

NB! The input and output files for this problem are quite large, which means that you have to be a bit careful about I/O efficiency.


For each test case, output the product of the two polynomials, in the same format as in the input (including the degree). All coefficients in the result will fit in a signed 32-bit integer.

Sample Input 1 Sample Output 1
1 0 5
0 -2
0 -2 0 -10

Please log in to submit a solution to this problem

Log in