var i,j,x,a:integer;
d:array [1..3,1..50,1..50] of real;
b:array [1..3] of integer;
begin
write('Nhap tong so bien cua ca hai dt (cac bien trung nhau chi tinh 1 lan): ');readln(a);
for x:=1 to 2 do
begin
write('Nhap bac cua dt ',x,': ');readln(b[x]);
write('Ct dang chung cua dt ',x,' : ');
for i:= 97 to 97+a[x]-1 do
for j:=b[x] downto 1 do write('+ ',chr(i),'^',j,' ');
writeln;
for i:=97 to 97+a[x]]-1 do
for j:=b[x] downto 1 do
begin
write('Nhap he so cua ',chr(i),'^',j,' trong dt ',x,' (neu khong co thi ghi 0): '); readln(d[x,i,j]);
end;
end;
if b[1]>b[2] then b[3]:=b[1] else b[3]:=b[2];
for i:=97 to 97+a do for j:=b[3]downto 1 do d[3,i,j]:=d[1,i,j]+d[2,i,j];
writeln('Tong cua 2 da thuc la: ');
for i:= 97 to 97+a-1 do
j:=b[3] downto 1 do write('+ (',d[3,i,j]:4:2,chr(i),'^',j,') ');
readln
end.