import Control.Monad
import Control.Monad.State
import Data.List

type Stations = [(Int, Int, Int)]

cal :: Int -> State Stations Int
cal a = do ss <- get
           case ss == [] of
             True  -> return a
             False -> do ((t, s, e):xs) <- get
                         put xs
                         case a < s of
                           True  -> cal ( t + s )
                           False -> cal ( t + (head [ y * e | y <- [1..], y * e >= a ]) )

main = do
  n  <- readLn
  cs <- replicateM (n-1) getLine
  let tpls = map (ltp . map ri . words) cs
  mapM_ (print . fst) $ map (runState (cal 0)) $ tails tpls

ri :: String -> Int
ri = read

ltp :: [Int] -> (Int, Int, Int)
ltp (x:y:z:ss) = (x, y, z)