n=int(eval(input()))

ab = []

for _ in range(n-1):

    a, b, c = (int(x) for x in input().split())

    ab.append([a, b, c])



for i in range(n-1):

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

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

        if ans <= ab[j][1]:

            ans = ab[j][1]

        elif (ans-ab[j][1])%ab[j][2]!=0:

            ans += ab[j][2]-(ans-ab[j][1])%ab[j][2]

        ans += ab[j][0]

    print(ans)

        

print((0))
N = int(eval(input()))

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



for i in range(N-1):

    c1,s1,f1 = Plan[i]

    time = s1+c1

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

        c,s,f = Plan[j]

        if time <= s:

            time = s

        elif (time-s)%f != 0:

            time += f-(time-s)%f

        time += c

    print(time)

print((0))
n = int(eval(input()))
ab = []
for _ in range(n - 1):
    a, b, c = (int(x) for x in input().split())
    ab.append([a, b, c])
for i in range(n - 1):
    ans = ab[i][0] + ab[i][1]
    for j in range(i + 1, n - 1):
        if ans <= ab[j][1]:
            ans = ab[j][1]
        elif (ans - ab[j][1]) % ab[j][2] != 0:
            ans += ab[j][2] - (ans - ab[j][1]) % ab[j][2]
        ans += ab[j][0]
    print(ans)
print((0))

N = int(eval(input()))
Plan = [list(map(int, input().split())) for _ in range(N - 1)]
for i in range(N - 1):
    c1, s1, f1 = Plan[i]
    time = s1 + c1
    for j in range(i + 1, N - 1):
        c, s, f = Plan[j]
        if time <= s:
            time = s
        elif (time - s) % f != 0:
            time += f - (time - s) % f
        time += c
    print(time)
print((0))

-n = int(eval(input())) -ab = [] -for _ in range(n - 1): -    a, b, c = (int(x) for x in input().split()) -    ab.append([a, b, c]) -for i in range(n - 1): -    ans = ab[i][0] + ab[i][1] -    for j in range(i + 1, n - 1): -        if ans <= ab[j][1]: -            ans = ab[j][1] -        elif (ans - ab[j][1]) % ab[j][2] != 0: -            ans += ab[j][2] - (ans - ab[j][1]) % ab[j][2] -        ans += ab[j][0] -    print(ans) +N = int(eval(input())) +Plan = [list(map(int, input().split())) for _ in range(N - 1)] +for i in range(N - 1): +    c1, s1, f1 = Plan[i] +    time = s1 + c1 +    for j in range(i + 1, N - 1): +        c, s, f = Plan[j] +        if time <= s: +            time = s +        elif (time - s) % f != 0: +            time += f - (time - s) % f +        time += c +    print(time)