import math

n=int(eval(input()))

c=[]

s=[]

f=[]

for i in range(n-1):

    C,S,F=list(map(int,input().split()))

    c.append(C)

    s.append(S)

    f.append(F)





for j in range(n-1):

    t=s[j]

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



        if t<=s[i]:

            t=s[i]+c[i]

        else:

            k=t-s[i]

            t=s[i]+math.ceil(k/f[i])*f[i]+c[i]

    print( t)



print((0))

import math

n=int(eval(input()))

csf=[list(map(int,input().split())) for i in range(n-1)]



for j in range(n-1):

    now=0

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

        if csf[i][1]>=now:

            now=csf[i][1]+csf[i][0]

        else:

            now=csf[i][1]-((csf[i][1]-now)//csf[i][2])*csf[i][2]+csf[i][0]

    print(now)

print((0))



import math

n = int(eval(input()))
c = []
s = []
f = []
for i in range(n - 1):
    C, S, F = list(map(int, input().split()))
    c.append(C)
    s.append(S)
    f.append(F)
for j in range(n - 1):
    t = s[j]
    for i in range(j, n - 1):
        if t <= s[i]:
            t = s[i] + c[i]
        else:
            k = t - s[i]
            t = s[i] + math.ceil(k / f[i]) * f[i] + c[i]
    print(t)
print((0))

import math

n = int(eval(input()))
csf = [list(map(int, input().split())) for i in range(n - 1)]
for j in range(n - 1):
    now = 0
    for i in range(j, n - 1):
        if csf[i][1] >= now:
            now = csf[i][1] + csf[i][0]
        else:
            now = csf[i][1] - ((csf[i][1] - now) // csf[i][2]) * csf[i][2] + csf[i][0]
    print(now)
print((0))

-c = [] -s = [] -f = [] -for i in range(n - 1): -    C, S, F = list(map(int, input().split())) -    c.append(C) -    s.append(S) -    f.append(F) +csf = [list(map(int, input().split())) for i in range(n - 1)] -    t = s[j] +    now = 0 -        if t <= s[i]: -            t = s[i] + c[i] +        if csf[i][1] >= now: +            now = csf[i][1] + csf[i][0] -            k = t - s[i] -            t = s[i] + math.ceil(k / f[i]) * f[i] + c[i] -    print(t) +            now = csf[i][1] - ((csf[i][1] - now) // csf[i][2]) * csf[i][2] + csf[i][0] +    print(now)