from sys import stdin



n = int(eval(input()))

s = [stdin.readline().rstrip().split() for i in range(n-1)]



def kaisuu(s,i):

    t = int(s[i][0]) + int(s[i][1])

    if i != n-1:

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

            if  t <= int(s[j][1]):

                t = int(s[j][0]) + int(s[j][1])

            elif t % int(s[j][2]) == 0:

                t = t + int(s[j][0])

            else:

                t = t + int(s[j][0]) + (int(s[j][2]) - t % int(s[j][2]))

    return t



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

    print((kaisuu(s,i)))



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

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



def kaisuu(s,i):

    t = s[i][0] + s[i][1]

    if i != n-1:

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

            if  t <= s[j][1]:

                t = s[j][0] + s[j][1]

            elif t % s[j][2] == 0:

                t = t + s[j][0]

            else:

                t = t + s[j][0] + (s[j][2] - t % s[j][2])

    return t



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

    print((kaisuu(s,i)))



print((0))
from sys import stdin

n = int(eval(input()))
s = [stdin.readline().rstrip().split() for i in range(n - 1)]


def kaisuu(s, i):
    t = int(s[i][0]) + int(s[i][1])
    if i != n - 1:
        for j in range(i + 1, n - 1):
            if t <= int(s[j][1]):
                t = int(s[j][0]) + int(s[j][1])
            elif t % int(s[j][2]) == 0:
                t = t + int(s[j][0])
            else:
                t = t + int(s[j][0]) + (int(s[j][2]) - t % int(s[j][2]))
    return t


for i in range(0, n - 1):
    print((kaisuu(s, i)))
print((0))

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


def kaisuu(s, i):
    t = s[i][0] + s[i][1]
    if i != n - 1:
        for j in range(i + 1, n - 1):
            if t <= s[j][1]:
                t = s[j][0] + s[j][1]
            elif t % s[j][2] == 0:
                t = t + s[j][0]
            else:
                t = t + s[j][0] + (s[j][2] - t % s[j][2])
    return t


for i in range(0, n - 1):
    print((kaisuu(s, i)))
print((0))

-from sys import stdin - -s = [stdin.readline().rstrip().split() for i in range(n - 1)] +s = [list(map(int, input().split())) for i in range(n - 1)] -    t = int(s[i][0]) + int(s[i][1]) +    t = s[i][0] + s[i][1] -            if t <= int(s[j][1]): -                t = int(s[j][0]) + int(s[j][1]) -            elif t % int(s[j][2]) == 0: -                t = t + int(s[j][0]) +            if t <= s[j][1]: +                t = s[j][0] + s[j][1] +            elif t % s[j][2] == 0: +                t = t + s[j][0] -                t = t + int(s[j][0]) + (int(s[j][2]) - t % int(s[j][2])) +                t = t + s[j][0] + (s[j][2] - t % s[j][2])