You are given two polynomials:
$$A(x) = a_0 + a_1x + a_2x^2 + \dots + a_{n-1}x^{n-1} + a_nx^n$$
$$B(x) = b_0 + b_1x + b_2x^2 + \dots + b_{m-1}x^{m-1} + b_mx^m$$
You have to multiply them and print the resulting polynomial.
Input
Input starts with an integer T (≤ 13), denoting the number of test cases.
Each case contains two polynomials in separate lines. Each polynomial is defined as an integer k (0 ≤ k < 50,000) denoting the degree of the polynomial followed by k + 1 integers (separated by a single space) describing the coefficients from a0, a1, ..., ak. Coefficients will lie in the range [-100, 100]. Assume that each polynomial is a valid k degree polynomial.
Output
For each case, print the case number followed by the resulting polynomial in the same form as input. See the samples for more details.
Sample
Sample Input | Sample Output |
---|---|
3 3 1 2 3 4 2 -8 9 10 1 -89 -90 1 80 -89 2 3 2 1 2 5 0 2 | Case 1: 5 -8 -7 4 15 66 40 Case 2: 2 -7120 721 8010 Case 3: 4 15 10 11 4 2 |
Notes
Dataset is huge, use faster I/O methods.
For the 3rd case,
We are multiplying (x^2 + 2x + 3)(2x^2 + 5) = 2x^2 + 0x + 5 1x^2 + 2x + 3 ---------------- 6 0 15 4 0 10 2 0 5 ------------------------------- 2x^4 + 4x^3 + 11x^2 + 10x + 15