HZNUOJ

Product of Polynomials(施工中)

Tags:
Time Limit:  4 s      Memory Limit:   128 MB
Submission:11     AC:4     Score:99.83

Description

You are supposed to find A*B where A and B are two polynomials.

Input

Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial: K N1 aN1 N2 aN2 ... NK aNK, where K is the number of nonzero terms in the polynomial, Ni and aNi (i=1, 2, ..., K) are the exponents and coefficients, respectively. It is given that 1 <= K <= 2*105, 0 <= N1 < ... < Nk-1 < Nk <=2*105 and aNi is integer 1<=aNi<=100

Output

For each test case you should output the product of A and B in one line, with the same format as the input,except for K you should not output  the number of nonzero terms in the polynomial. Notice that there must be NO extra space at the end of each line. Please be accurate up to 1 decimal place. 

Samples

input
2 0 3 1 2 2 1 5 2 1
output
1 15 2 13 3 2

Hint

(x2+5x)*(2x+3)=2x3+13x2+15x

so the answer is 3 2 2 13 1 15

Adapted from PAT A 1009

Author

HU, Jiacheng