main :: IO ()
main = interact $ unlines . map show . solve . reverse . drop 3 . reverse . words

solve :: [String] -> [Int]
solve [] = []
solve (a:x:b:xs)
    | x == "+" = k + l : ys
    | x == "-" = k - l : ys
    | x == "*" = k * l : ys
    | x == "/" = k `div` l : ys
    where
        k = (read :: String -> Int) a
        l = (read :: String -> Int) b
        ys = solve xs
