import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    csf <- replicateM (n-1) $ do
        [c,s,f] <- getIntList
        return (c,s,f)
    mapM_ print . map (foldl' solve 0) $ tails csf

solve t (c,s,f) = c + max s (t + ((-t) `mod` f))