# 实现多项式的基本运算

#include<iostream>
#include<stdlib.h>
using namespace std;
{
public:
int data;
int exp;
{
data = x;
exp = y;
}
};
class List
{
public:
List ()
{
first = new LinkNode(0,-1);
}
~List ()
{
delete first;
}
void lian(int &x,int &y);
void output1(int i);
void output2();
void paixu();
void jiafa(List &a);
void qiudao();
void qiuzhi(int);
};

void List::lian(int &x, int &y)//xishu and zhishu
{
{
}
}

void List::paixu()//系数从小到大排序
{
int l = 0;
{
l++;
}
int i = 0;
for(i=0; i<l; i++)
{
p=first;
q=NULL;
{
{
}
}
}
}

void List ::jiafa(List  &b)//多项式假发
{
List  c;
while (k != NULL)
{
c.lian(k->data, k->exp);
}
int flag = 1;
while (p != NULL)
{
flag = 1;
while (q != NULL)
{
if (p->exp == q->exp)
{
q->data = q->data + p->data;
flag = 0;
}
}
if (flag)
{
c.lian(p->data, p->exp);
}
}
c.paixu();
c.output2();
}

void List::qiudao()//多项式求导，exp-1乘data
{
List a;
while(k!=NULL)
{
a.lian(k->data,k->exp);
}
while(k!=NULL)
{
k->data=(k->data)*(k->exp);
k->exp=k->exp-1;
}
a.output2();
}

void List::qiuzhi(int x)
{
int s = 0;
int q = 1;
while(p!= NULL)
{
q=1;
for (int i=0; i<p->exp; i++)
{
q=q*x;
}
s=s+p->data*q;
}
cout<<s<<endl;
}

void List::output1(int i)
{
{
cerr<<"该链表为空!!!!!"<<endl;
exit(1);
}
for(int k=1; k <i; k++)
{
{
cerr<<"是无效的位置!!!!!!!!!!!"<<endl;
exit(1);
}
else
{
}
}

cout<<current->data<<endl;
}

void List::output2()
{
{
cerr<<"链表为空!!!!!!"<<endl;
exit(1);
}
int i = 1;
while(current != NULL)
{
if(current->data==0)
{
continue;
}

if (i != 1)
{
if (current->data == 1)
{
cout << "+";
}
else if (current->data > 1)
{
cout << "+" << current->data;
}
else{
cout << current->data;
}
}
else
{
if (current->data == 1) {  }
else{
cout << current->data;
}
}

if (current->exp != 1)
{
cout << "x^";
cout << current->exp;
}
else
{
cout << "x";
}
i++;
}
cout<<endl;
}
int main()
{
int i,a,b,e,f,g;
List la;
List lb;
cin>>a;
for (i=0;i<a;i++)
{
cin>>e>>f;
la.lian(e, f);
}
cin>>b;
for(i=0;i<b;i++)
{
cin>>e>>f;
lb.lian(e,f);
}
cin>>g;
cout<<"A(x)+B(x)=";
la.jiafa(lb);
cout<<"A'(x)=";
la.qiudao();
cout<<"A("<<g<<")=";
la.qiuzhi(g);
return 0;
}