var
a:array[1..100]of longint;
i,j,n,last:longint;
begin
readln(n);
for i:=1 to n do
read(a[i]); read(last);
if (a[1]<>1)and(a[1]<>-1) then
begin
if a[1]>0 then write(a[1],'x^',n);
if a[1]<0 then write(a[1],'x^',n);
end;
if a[1]=1 then write('x^',n);
if a[1]=-1 then write('-x^',n);
for i:=2 to n do
begin
if (n-i+1)<>1 then
begin
if (a[i]<>1)and(a[i]<>-1) then
begin
if a[i]>0 then write('+',a[i],'x^',n-i+1);
if a[i]<0 then write(a[i],'x^',n-i+1);
end;
if a[i]=1 then write('+x^',n-i+1);
if a[i]=-1 then write('-x^',n-i+1);
end;
if (n-i+1)=1 then
begin
if (a[i]<>1)and(a[i]<>-1) then
begin
if a[i]>0 then write('+',a[i],'x');
if a[i]<0 then write(a[i],'x');
end;
if a[i]=1 then write('+x');
if a[i]=-1 then write('-x');
end;
end;
if last>0 then write('+',last);
if last<0 then write(last);
end.
a:array[1..100]of longint;
i,j,n,last:longint;
begin
readln(n);
for i:=1 to n do
read(a[i]); read(last);
if (a[1]<>1)and(a[1]<>-1) then
begin
if a[1]>0 then write(a[1],'x^',n);
if a[1]<0 then write(a[1],'x^',n);
end;
if a[1]=1 then write('x^',n);
if a[1]=-1 then write('-x^',n);
for i:=2 to n do
begin
if (n-i+1)<>1 then
begin
if (a[i]<>1)and(a[i]<>-1) then
begin
if a[i]>0 then write('+',a[i],'x^',n-i+1);
if a[i]<0 then write(a[i],'x^',n-i+1);
end;
if a[i]=1 then write('+x^',n-i+1);
if a[i]=-1 then write('-x^',n-i+1);
end;
if (n-i+1)=1 then
begin
if (a[i]<>1)and(a[i]<>-1) then
begin
if a[i]>0 then write('+',a[i],'x');
if a[i]<0 then write(a[i],'x');
end;
if a[i]=1 then write('+x');
if a[i]=-1 then write('-x');
end;
end;
if last>0 then write('+',last);
if last<0 then write(last);
end.