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: def examA():
      C1 = SI()
      C2 = SI()
      ans = "YES"
      if C1[0] != C2[2] or C1[1] != C2[1] or C1[2] != C2[0]:
          ans = "NO"
      print(ans)
      return
  
  
  def examB():
      A, B, C, X, Y = LI()
      loop = max(X, Y)
      ans = inf
      for i in range(loop + 1):
          cost = i * 2 * C
          if X > i:
              cost += A * (X - i)
          if Y > i:
              cost += B * (Y - i)
          ans = min(ans, cost)
      print(ans)
      return
  
  
  def examC():
      def gcd(x, y):
          if y == 0:
              return x
          while y != 0:
              x, y = y, x % y
          return x
  
      N, x = LI()
      X = LI()
      if N == 1:
          print(abs(X[0] - x))
          return
      for i in range(N):
          X[i] = abs(X[i] - x)
      now = gcd(X[0], X[1])
      for i in range(2, N):
          now = gcd(now, X[i])
      ans = now
      print(ans)
      return
  
  
  def examD():
      N = I()
      C = [LI() for _ in range(N - 1)]
      ans = [inf] * N
      for i in range(N):
          cur = 0
          for j in range(i, N - 1):
              c, s, f = C[j]
              next = 0
              if cur <= s:
                  cur = s + c
              else:
                  cur = (1 + (cur - 1) // f) * f + c
          ans[i] = cur
      for v in ans:
          print(v)
      return
  
  
  def examE():
      ans = 0
      print(ans)
      return
  
  
  def examF():
      ans = 0
      print(ans)
      return
  
  
  from decimal import Decimal as dec
  import sys, bisect, itertools, heapq, math, random
  from copy import deepcopy
  from heapq import heappop, heappush, heapify
  from collections import Counter, defaultdict, deque
  
  read = sys.stdin.buffer.read
  readline = sys.stdin.buffer.readline
  readlines = sys.stdin.buffer.readlines
  
  
  def I():
      return int(input())
  
  
  def LI():
      return list(map(int, sys.stdin.readline().split()))
  
  
  def DI():
      return dec(input())
  
  
  def LDI():
      return list(map(dec, sys.stdin.readline().split()))
  
  
  def LSI():
      return list(map(str, sys.stdin.readline().split()))
  
  
  def LS():
      return sys.stdin.readline().split()
  
  
  def SI():
      return sys.stdin.readline().strip()
  
  
  global mod, mod2, inf, alphabet, _ep
  mod = 10**9 + 7
  mod2 = 998244353
  inf = 10**18
  _ep = 10 ** (-12)
  alphabet = [chr(ord("a") + i) for i in range(26)]
  
  sys.setrecursionlimit(10**7)
  
  if __name__ == "__main__":
      examD()
  
  """
  142
  12 9 1445 0 1
  asd dfg hj o o
  aidn
  """
  
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"}]