# coding: utf-8

import math

N = int(eval(input()))

sta_info = []

for i in range(N-1):

    l = list(map(int,input().split()))

    sta_info.append(l)



for i in range(N-1):

    start = i

    t = 0

    ans = 0

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

        c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2]

        #print('到着時 ' + str(t))

        if t <= s:

            t = s

            #print('!!!')

        else:

            n = math.ceil((t - s) / f)

            t += s + n * f - t

        #print('発車時 ' + str(t))

        t += c

        

    print(t)

print((0))

#coding: utf-8

import math

N = int(eval(input()))

L = []

for i in range(N-1):

    l = list(map(int,input().split()))

    L.append(l)



for i in range(N-1):

    t = 0

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

        l = L[j]

        c = l[0]

        s = l[1]

        f = l[2]

        if t <= s:

            t = s+c

        else:

            n = math.ceil((t-s)/f)

            t = s+n*f+c

    print(t)



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

N = int(eval(input()))
sta_info = []
for i in range(N - 1):
    l = list(map(int, input().split()))
    sta_info.append(l)
for i in range(N - 1):
    start = i
    t = 0
    ans = 0
    for j in range(i, N - 1):
        c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2]
        # print('到着時 ' + str(t))
        if t <= s:
            t = s
            # print('!!!')
        else:
            n = math.ceil((t - s) / f)
            t += s + n * f - t
        # print('発車時 ' + str(t))
        t += c
    print(t)
print((0))

# coding: utf-8
import math

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

-sta_info = [] +L = [] -    sta_info.append(l) +    L.append(l) -    start = i -    ans = 0 -        c, s, f = sta_info[j][0], sta_info[j][1], sta_info[j][2] -        # print('到着時 ' + str(t)) +        l = L[j] +        c = l[0] +        s = l[1] +        f = l[2] -            t = s -            # print('!!!') +            t = s + c -            t += s + n * f - t -        # print('発車時 ' + str(t)) -        t += c +            t = s + n * f + c