smoothie-web Problems Contests Ranking About
Login Register

J3 - Soup and Polynomials

data_usage Points
5
timer Time Limit
linear_scale Memory Limit
Created
1606189954127

Recently in math class, Soup has learned how to multiply polynomials. His teacher has recently assigned him NN problems for homework. But as he wants to play League with his Egirls, he has tasked you with writting him a program to solve all the problems.

Constraints

0N,M1040 \leq N , M \leq 10^4

The coefficients of the polynomial will be in between 00 and 10001000 inclusive.

Input Specifications

The first line will contain the integers NN and MM, denoting the number of coefficients in the first polynomial and the second polynomial.

The next line of input will contain NN integers the coefficient of the first polynomial.

The final line of will contain MM integers, the coefficients of the second polynomial.

Output Specifications

Output N+M1N+M-1 integers, representing the coefficients of the resulting polynomial.

Sample Input 1

3 2
9 7 4
11 3

Sample Output 1

99 104 65 12

Sample Explanation 1

The two polynomials are 9+7x+4x29 + 7x + 4x^2 and 11+3x11 + 3x. The product will be 99+104x+65x2+12x399 + 104x + 65x^2 + 12x^3. Thus, the coefficient of the terms will be 99,104,6599, 104, 65 and 1212.

Sample Input 2

7 12
9 2 7 4 6 2 14
8 9 1 3 10 5 6 4 7 0 17 11

Sample Output 2

72 97 83 124 187 160 282 269 213 158 404 267 275 215 244 100 260 154