program express;
var p:array['('..'^']of integer;
s,m:string;
a:array[0..1000]of longint;
b,c:array[1..1000]of char;
t,k,n,j,i,x,y,oo:longint;
begin
assign(input,'express.in');
reset(input);
assign(output,'express.out');
rewrite(output);
readln(s);
p['(']:=1;
p[')']:=5;
p['+']:=2;
p['-']:=2;
p['*']:=3;
p['/']:=3;
p['^']:=4;
for t:=1 to length(s) do
begin
if (s[t]>='0')and(s[t]<='9') then
begin
inc(x);
a[x]:=ord(s[t])-ord('0');
end
else
begin
inc(y);
b[y]:=s[t];
if y>2 then
if b[y]<>')' then
repeat
if (y>1)and(p[b[y]]<=p[b[y-1]])then
begin
inc(x);
c[x]:=b[y-1];
dec(y);
inc(oo);
b[y]:=b[y+1];
end;
until (y>1)and(p[b[y]]>p[b[y-1]])or(y=1)
else if b[y]=')' then
begin
dec(y);
if b[y]<>'(' then
repeat
inc(x);
c[x]:=b[y];
dec(y);
inc(oo);
until b[y]='(';
dec(y);
end;
end;
end;
inc(x);
c[x]:=b[1];
for t:=1 to x do
if (c[t] in ['('..'^']) then write(c[t],' ')
else write(a[t],' ');
writeln;
repeat
for t:=1 to x do
if c[t] in ['('..'^'] then
begin
if c[t]='+' then a[t-2]:=a[t-1]+a[t-2]
else if c[t]='-' then a[t-2]:=a[t-2]-a[t-1]
else if c[t]='*' then a[t-2]:=a[t-1]*a[t-2]
else if c[t]='/' then a[t-2]:=a[t-2]div a[t-1]
else if c[t]='^' then
begin
j:=a[t-2];
if a[t-1]-1>0 then
for k:=1 to a[t-1]-1 do
a[t-2]:=a[t-2]*j;
end;
for k:=t-1 to x do
a[k]:=a[k+2];
for k:=t-1 to x do
c[k]:=c[k+2];
x:=x-2;
for k:=1 to x do
if (c[k] in ['('..'^']) then write(c[k],' ')
else write(a[k],' ');
writeln;
dec(oo);
break;
end;
until oo=-1;
close(input);
close(output);
end.