import Control.Monad
import Data.List

main = readLn >>= flip replicateM (map read . words <$> getLine) . (subtract 1) >>= mapM_ print . map (foldl (\t [c,s,f] -> c + max s (f * (div (t + f - 1) f))) 0) . tails