import Data.Int
import Data.Array.IArray

solve :: Int -> Array Int (Int64,Int64,Int64) -> [Int64]
solve n a = map (go 0) [1..n]
  where
    go :: Int64 -> Int -> Int64
    go t i
      | i == n = t
      | t <= s = go (s+c) (i+1)
      | otherwise = let t' = if t `mod` f == 0
                               then t else t + f - (t `mod` f) 
                     in go (t' + c) (i+1)
      where
        (c,s,f) = a!i

main :: IO ()
main = do
    n <- readLn :: IO Int
    a <- listArray (1,n-1) . map ((\[a,b,c] -> (a,b,c)) . (map read . words))
       . lines <$> getContents :: IO (Array Int (Int64,Int64,Int64))
    mapM_ print $ solve n a