Description:
The product and sum of the two unary polynomials are obtained by the design function respectively.
Input Specification:
Input is divided into 2 lines, each line is given the number of non-0 polynomial, and then the exponential degradation way to enter a polynomial non-0 coefficients and exponents (absolute value is not more than 1000 integers). The numbers are separated by a space.
Output Specification:
The output is divided into 2 rows, and the coefficients and exponents of the product polynomial and the polynomial non-0 are output in exponential degradation mode respectively. The numbers are separated by a space, but cannot have extra spaces at the end. The 0 polynomial should output 0 0.
Sample Input:
4 3 4-5 2 6 1-2 0
3 5 20-7 4 3 1
Sample Output:
15 24-25 22 30 21-10 20-21 8 35 6-33 5 14 4-15 3 18 2-6 1
5 20-4 4-5 2 9 1-2 0
Multiplication and addition operation of unary polynomial