n = (int)(eval(input()))  # num of station

cost = []  # list of costed timeto next

s = []  # list of init train time

freq = []  # list of freq of train departure

for i in range(n-1):

  a, b, c = (list)(list(map(int, input().split())))

  cost.append(a)

  s.append(b)

  freq.append(c)





def t(num):  # return time will cost to go from (num)station to end

  time = 0

  for j in range(num, n-1):

    if time < s[j]:  # if init train has not departed

      time = s[j]

    elif time % freq[j]:  # if next train has not arrived

      time = wait_next(time, freq[j])

    time += cost[j]  # add time to next station

  return time





def wait_next(now, freq):  # calc time we will wait to get next train

  while(1):

    if not now % freq:

      break

    now += 1

  return now





for i in range(n):

  print((t(i)))

n = (int)(eval(input()))  # num of station

cost = []  # list of costed timeto next

s = []  # list of init train time

freq = []  # list of freq of train departure

for i in range(n-1):

  a, b, c = (list)(list(map(int, input().split())))

  cost.append(a)

  s.append(b)

  freq.append(c)





def t(num):  # return time will cost to go from (num)station to end

  time = 0

  for j in range(num, n-1):

    if time < s[j]:  # if init train has not departed

      time = s[j]

    elif time % freq[j]:  # if next train has not arrived

      time = wait_next(time, freq[j])

    time += cost[j]  # add time to next station

  return time





def wait_next(now, freq):  # calc time we will wait to get next train

  while(1 and False):

    if not now % freq:

      break

    now += 1

#  return now

  return (now//freq+1)*freq





for i in range(n):

  print((t(i)))

n = (int)(eval(input()))  # num of station
cost = []  # list of costed timeto next
s = []  # list of init train time
freq = []  # list of freq of train departure
for i in range(n - 1):
    a, b, c = (list)(list(map(int, input().split())))
    cost.append(a)
    s.append(b)
    freq.append(c)


def t(num):  # return time will cost to go from (num)station to end
    time = 0
    for j in range(num, n - 1):
        if time < s[j]:  # if init train has not departed
            time = s[j]
        elif time % freq[j]:  # if next train has not arrived
            time = wait_next(time, freq[j])
        time += cost[j]  # add time to next station
    return time


def wait_next(now, freq):  # calc time we will wait to get next train
    while 1:
        if not now % freq:
            break
        now += 1
    return now


for i in range(n):
    print((t(i)))

n = (int)(eval(input()))  # num of station
cost = []  # list of costed timeto next
s = []  # list of init train time
freq = []  # list of freq of train departure
for i in range(n - 1):
    a, b, c = (list)(list(map(int, input().split())))
    cost.append(a)
    s.append(b)
    freq.append(c)


def t(num):  # return time will cost to go from (num)station to end
    time = 0
    for j in range(num, n - 1):
        if time < s[j]:  # if init train has not departed
            time = s[j]
        elif time % freq[j]:  # if next train has not arrived
            time = wait_next(time, freq[j])
        time += cost[j]  # add time to next station
    return time


def wait_next(now, freq):  # calc time we will wait to get next train
    while 1 and False:
        if not now % freq:
            break
        now += 1
    #  return now
    return (now // freq + 1) * freq


for i in range(n):
    print((t(i)))

-    while 1: +    while 1 and False: -    return now +    #  return now +    return (now // freq + 1) * freq