s=[]

p=s.pop

for e in input().split():

 s+=[e if e.isdigit() else str(eval(p(-2)+e+p()))]

print((*s))
s=[]

p=s.pop

for e in input().split():

 s+=[str(eval(p(-2)+e+p()))if e in'*+-'else e]

print((*s))
s = []
p = s.pop
for e in input().split():
    s += [e if e.isdigit() else str(eval(p(-2) + e + p()))]
print((*s))

s = []
p = s.pop
for e in input().split():
    s += [str(eval(p(-2) + e + p())) if e in "*+-" else e]
print((*s))

-    s += [e if e.isdigit() else str(eval(p(-2) + e + p()))] +    s += [str(eval(p(-2) + e + p())) if e in "*+-" else e]