output_description: Print N lines. Assuming that we are at Station i (1≤i≤N) when the ceremony
  begins, if the earliest possible time we can reach Station N is x seconds
  after the ceremony begins, the i-th line should contain x.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      C_1 S_1 F_1
      :
      C_{N-1} S_{N-1} F_{N-1}
attempt: import sys
  import math
  import copy
  import heapq
  from functools import cmp_to_key
  from bisect import bisect_left, bisect_right
  from collections import defaultdict, deque, Counter
  
  sys.setrecursionlimit(1000000)
  
  # input aliases
  input = sys.stdin.readline
  getS = lambda: input().strip()
  getN = lambda: int(input())
  getList = lambda: list(map(int, input().split()))
  getZList = lambda: [int(x) - 1 for x in input().split()]
  
  INF = float("inf")
  MOD = 10**9 + 7
  divide = lambda x: pow(x, MOD - 2, MOD)
  
  
  def nck(n, k, kaijyo):
      return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD
  
  
  def npk(n, k, kaijyo):
      if k == 0 or k == n:
          return n % MOD
      return (kaijyo[n] * divide(kaijyo[n - k])) % MOD
  
  
  def fact_and_inv(SIZE):
      inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
      fac = [0] * SIZE  # fac[j] = j! mod MOD
      finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
      inv[1] = 1
      fac[0] = fac[1] = 1
      finv[0] = finv[1] = 1
      for i in range(2, SIZE):
          inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
          fac[i] = fac[i - 1] * i % MOD
          finv[i] = finv[i - 1] * inv[i] % MOD
  
      return fac, finv
  
  
  def renritsu(A, Y):
      # example 2x + y = 3, x + 3y = 4
      # A = [[2,1], [1,3]])
      # Y = [[3],[4]] または [3,4]
      A = np.matrix(A)
      Y = np.matrix(Y)
      Y = np.reshape(Y, (-1, 1))
      X = np.linalg.solve(A, Y)
  
      # [1.0, 1.0]
      return X.flatten().tolist()[0]
  
  
  class TwoDimGrid:
      # 2次元座標 -> 1次元
      def __init__(self, h, w, wall="#"):
          self.h = h
          self.w = w
          self.size = (h + 2) * (w + 2)
          self.wall = wall
          self.get_grid()
          # self.init_cost()
  
      def get_grid(self):
          grid = [self.wall * (self.w + 2)]
          for i in range(self.h):
              grid.append(self.wall + getS() + self.wall)
  
          grid.append(self.wall * (self.w + 2))
          self.grid = grid
  
      def init_cost(self):
          self.cost = [INF] * self.size
  
      def pos(self, x, y):
          # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
          return y * (self.w + 2) + x
  
      def getgrid(self, x, y):
          return self.grid[y][x]
  
      def get(self, x, y):
          return self.cost[self.pos(x, y)]
  
      def set(self, x, y, v):
          self.cost[self.pos(x, y)] = v
          return
  
      def show(self):
          for i in range(self.h + 2):
              print(self.cost[(self.w + 2) * i : (self.w + 2) * (i + 1)])
  
      def showsome(self, tgt):
          for t in tgt:
              print(t)
          return
  
      def showsomejoin(self, tgt):
          for t in tgt:
              print("".join(t))
          return
  
      def search(self):
          grid = self.grid
          move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
          move_eight = [
              (0, 1),
              (0, -1),
              (1, 0),
              (-1, 0),
              (1, 1),
              (1, -1),
              (-1, 1),
              (-1, -1),
          ]
          # for i in range(1, self.h+1):
          #     for j in range(1, self.w+1):
          #         cx, cy = j, i
          #         for dx, dy in move_eight:
          #             nx, ny = dx + cx, dy + cy
  
  
  def soinsu(n):
      ret = defaultdict(int)
      for i in range(2, int(math.sqrt(n) + 2)):
          if n % i == 0:
              while True:
                  if n % i == 0:
                      ret[i] += 1
                      n //= i
                  else:
                      break
  
      if not ret:
          return {n: 1}
      return ret
  
  
  def solve():
      n = getN()
      den = []
      ans = [0 for i in range(n)]
      for i in range(n - 1):
          den.append(getList())
  
      den.append([0, 0, 0])
  
      # for i in range(1,n):
      #     tgt = n - i - 1
      #     tou = den[tgt][1] + den[tgt][0]
      #     if tou <= den[tgt+1][1]:
      #         ans[tgt] = ans[tgt+1]
      #
      for i in range(n - 1):
          cur = 0
          for j in range(i, n - 1):
              if cur <= den[j][1]:
                  cur = den[j][1]
              cur = int(math.ceil(cur / den[j][2]) * den[j][2])
              cur += den[j][0]
          ans[i] = cur
  
      print(*ans, sep="\n")
  
  
  def main():
      n = getN()
      for _ in range(n):
          solve()
  
      return
  
  
  if __name__ == "__main__":
      # main()
      solve()
  
problem_description: Statement
  
  A railroad running from west to east in Atcoder Kingdom is now complete.
  
  There are N stations on the railroad, numbered 1 through N from west to east.
  
  Tomorrow, the opening ceremony of the railroad will take place.
  
  On this railroad, for each integer i such that 1≤i≤N-1, there will be trains
  that run from Station i to Station i+1 in C_i seconds. No other trains will be
  operated.
  
  The first train from Station i to Station i+1 will depart Station i S_i
  seconds after the ceremony begins. Thereafter, there will be a train that
  departs Station i every F_i seconds.
  
  Here, it is guaranteed that F_i divides S_i.
  
  That is, for each Time t satisfying S_i≤t and t％F_i=0, there will be a train
  that departs Station i t seconds after the ceremony begins and arrives at
  Station i+1 t+C_i seconds after the ceremony begins, where A％B denotes A
  modulo B, and there will be no other trains.
  
  For each i, find the earliest possible time we can reach Station N if we are
  at Station i when the ceremony begins, ignoring the time needed to change
  trains.
samples: [{"input": "3\n    6 5 1\n    1 10 1", "output": "12\n    11\n    0\n    \n\nWe will travel from Station 1 as follows:\n\n  * 5 seconds after the beginning: take the train to Station 2.\n  * 11 seconds: arrive at Station 2.\n  * 11 seconds: take the train to Station 3.\n  * 12 seconds: arrive at Station 3.\n\nWe will travel from Station 2 as follows:\n\n  * 10 seconds: take the train to Station 3.\n  * 11 seconds: arrive at Station 3.\n\nNote that we should print 0 for Station 3.\n\n* * *"}, {"input": "4\n    12 24 6\n    52 16 4\n    99 2 2", "output": "187\n    167\n    101\n    0\n    \n\n* * *"}, {"input": "4\n    12 13 1\n    44 17 17\n    66 4096 64", "output": "4162\n    4162\n    4162\n    0"}]