# coding: utf-8

import math



N = int(input())

CSF = [list(map(float, input().split())) for _ in range(N-1)]



for i in range(N-1):

    ans = CSF[i][0] + CSF[i][1]

    for j in range(i+1, N-1):

        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2]

        if t < ans:

            n = int(math.ceil((ans - t) / u))

            ans = int(s + t + u * n)

        else:

            ans = s + t



    print(int(ans))



print(0)
import math



N = int(input())

CSF = [list(map(float, input().split())) for _ in range(N-1)]



for i in range(N-1):

    ans = CSF[i][0] + CSF[i][1]

    for j in range(i+1, N-1):

        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]

        if S < ans:

            n = math.ceil((ans - S) / F)

            ans = C + S + F * n

        else:

            ans = C + S

 

    print(int(ans))



print(0)
# coding: utf-8
import math

N = int(input())
CSF = [list(map(float, input().split())) for _ in range(N - 1)]
for i in range(N - 1):
    ans = CSF[i][0] + CSF[i][1]
    for j in range(i + 1, N - 1):
        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2]
        if t < ans:
            n = int(math.ceil((ans - t) / u))
            ans = int(s + t + u * n)
        else:
            ans = s + t
    print(int(ans))
print(0)

import math

N = int(input())
CSF = [list(map(float, input().split())) for _ in range(N - 1)]
for i in range(N - 1):
    ans = CSF[i][0] + CSF[i][1]
    for j in range(i + 1, N - 1):
        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]
        if S < ans:
            n = math.ceil((ans - S) / F)
            ans = C + S + F * n
        else:
            ans = C + S
    print(int(ans))
print(0)

-# coding: utf-8 -        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2] -        if t < ans: -            n = int(math.ceil((ans - t) / u)) -            ans = int(s + t + u * n) +        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2] +        if S < ans: +            n = math.ceil((ans - S) / F) +            ans = C + S + F * n -            ans = s + t +            ans = C + S