{-# OPTIONS_GHC -O #-}

import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main=do
    n <- readLn
    ss <- replicateM (n-1) $ unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    --
    forM_ (tails ss) $ \s -> do print $ solve 0 s

solve t [] = t
solve t (([c,s,f]):ss)
    | t < s = solve (s+c) ss
    | True  = solve (((t+f-1)`div`f)*f+c) ss