import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import Data.Char

toTriple :: B.ByteString -> (Int, Int, Int)
toTriple bs =
    let
        Just (a, bs') = B.readInt bs
        Just (b, bs'') = B.readInt $ B.dropWhile isSpace bs'
        Just (c, _) = B.readInt $ B.dropWhile isSpace bs''
    in
        (a, b, c)

solve :: VU.Vector (Int, Int, Int) -> Int -> VU.Vector Int
solve csfs n = 
    VU.generate n $ \i -> 
        if i == n
            then 0
            else scan (VU.drop i csfs)
    where
        scan vec = VU.foldl' step 0 vec
        step acc (c,s,f)
            | acc < s = acc + (s - acc) + c
            | acc `rem` f == 0 = acc + c
            | otherwise = acc + (f - acc `rem` f) + c

main = do
    n <- readLn :: IO Int
    csfs <- VU.replicateM (n-1) (toTriple <$> B.getLine)
    VU.mapM_ print $ solve csfs n 