Time Limit: 1 Sec Memory Limit: 128 MB
Linked List is one of most simple and fundamental data structure, thus it has a very wide application. For example, linked list can be used to calculate the sum of two polynomials. Now, given two polynomials by the coefficient and exponent of each term, please output the sum of the two polynomials.
First line will be a positive integer
The first line will be an integer
After
(
For each test case, print the polynomial in ascending order of each exponents. Be attention to the format of the polynomial.
2
2
1 2
2 3
2
2 2
1 4
2
2 0
-2 1
2
3 1
1 2
3x^2+2x^3+x^4
2+x+x^2