Hide

Problem D
Polynomial Multiplication 1

Input

Standard input begins with an integer $T \le 100$, the number of test cases.

Each test case consists of two polynomials. A polynomial is given by an integer $1 \le n \le 255$ 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.

Output

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
2
2
1 0 5
1
0 -2
4
1 1 -1 1 1
4
9 -8 7 6 5
3
0 -2 0 -10
8
9 1 -10 30 5 -2 8 11 5

Please log in to submit a solution to this problem

Log in