N = int(eval(input()))

dia = []

for _ in range(N-1):

    c,s,f = list(map(int,input().split()))

    dia.append((c,s,f))

for i in range(N-1):

    time = 0

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

        c,s,f = dia[j]

        while time > s:

            s += f



        time = s + c

    print(time)

print((0))

















N = int(eval(input()))

dia = [0]*(N-1)

for i in range(N-1):

    c,s,f = list(map(int,input().split()))

    dia[i] = (c,s,f)

for i in range(N-1):

    time = 0

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

        c,s,f = dia[j]

        if time > s:

            x = (time - s)/f

            if x.is_integer():

                s += int(x)*f

            else:

                s += int(x+1)*f

        time =  s + c



        # while time > s:

        #     s += f

        # time = s + c



    print(time)

print((0))

















N = int(eval(input()))
dia = []
for _ in range(N - 1):
    c, s, f = list(map(int, input().split()))
    dia.append((c, s, f))
for i in range(N - 1):
    time = 0
    for j in range(i, N - 1):
        c, s, f = dia[j]
        while time > s:
            s += f
        time = s + c
    print(time)
print((0))

N = int(eval(input()))
dia = [0] * (N - 1)
for i in range(N - 1):
    c, s, f = list(map(int, input().split()))
    dia[i] = (c, s, f)
for i in range(N - 1):
    time = 0
    for j in range(i, N - 1):
        c, s, f = dia[j]
        if time > s:
            x = (time - s) / f
            if x.is_integer():
                s += int(x) * f
            else:
                s += int(x + 1) * f
        time = s + c
        # while time > s:
        #     s += f
        # time = s + c
    print(time)
print((0))

-dia = [] -for _ in range(N - 1): +dia = [0] * (N - 1) +for i in range(N - 1): -    dia.append((c, s, f)) +    dia[i] = (c, s, f) -        while time > s: -            s += f +        if time > s: +            x = (time - s) / f +            if x.is_integer(): +                s += int(x) * f +            else: +                s += int(x + 1) * f +        # while time > s: +        #     s += f +        # time = s + c