﻿ Ningbo University of Technology Online Judge ::  The Sum of F(x) and G(x)
• ###  The Sum of F(x) and G(x)

• 时间限制: 1000 ms　内存限制: 65535 K
• 问题描述
• When Deathmoon played MC game, he faced a math problem. When he found a ancient tomb and came in, he found two polynomials f(x) and g(x) no the wall, only did he calculate f(x) + g(x) correctly he could come in, can you help him?
For example:
f(x) = 2*x^5 + 3*x^3 + 7 + x^(-1),
g(x) = 3*x^4 + 2*x^3 + x - x^(-1).
Then,
f(x) + g(x) = 2*x^5 + 3*x^4 + 5*x^3 + x + 7

• 输入
• Input end of EOF.
First I will give you two positive integers N and M(0 < N, M < 10) means the number of items in polynomials.
Then N lines follow, each line contains two integers c(-100 < c < 100) and p(-10 <= p <= 10), c means the coefficients and p means the power.
Then M lines follow, each line contains two integers c(-100 < c < 100) and p(-10 <= p <= 10), c means the coefficients and p means the power.
And for each test, every polynomial' s power is descending, it means pi > pj when i < j.
c != 0 && p != 0.
• 输出
• You should output (f(x) + g(x))' s expression for coefficients and powers in descending.
• 样例输入
• ```4 4
2 5
3 3
7 0
1 -1
3 4
2 3
1 1
-1 -1
```
• 样例输出
• ```2 5
3 4
5 3
1 1
7 0
```
• 提示
• ```f(x) = coefficients * x ^ power;
The sample input:
f(x) = 2*x^5 + 3*x^3 + 7 + x^(-1),
g(x) = 3*x^4 + 2*x^3 + x - x^(-1).
The sample output:
f(x) + g(x) = 2*x^5 + 3*x^4 + 5*x^3 + x + 7
```
• 来源
• `Hungar`
• 操作
﻿ 