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 i in range(n):

    t = 0

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

        if t <= S[j]:

            t = S[j]

        elif (t - S[j]) % F[j] == 0:

             pass

        else:

            t += F[j] - (t - S[j]) % F[j]

        t += C[j]

    print(t)
import sys



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

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



    for i in range(n):

        if i == n - 1:

            print((0))

            break

        c1, s1, _ = CSF[i]

        t = s1 + c1

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

            c2, s2, f2 = CSF[j]

            if t <= s2:

                t = s2 + c2

            else:

                if t % f2 == 0:

                    wait = 0

                else:

                    wait = f2 - (t - s2) % f2

                t += c2 + wait

        print(t)





if __name__ == '__main__':

    resolve()

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 i in range(n):
    t = 0
    for j in range(i, n - 1):
        if t <= S[j]:
            t = S[j]
        elif (t - S[j]) % F[j] == 0:
            pass
        else:
            t += F[j] - (t - S[j]) % F[j]
        t += C[j]
    print(t)

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    CSF = [list(map(int, input().split())) for _ in range(n - 1)]
    for i in range(n):
        if i == n - 1:
            print((0))
            break
        c1, s1, _ = CSF[i]
        t = s1 + c1
        for j in range(i + 1, n - 1):
            c2, s2, f2 = CSF[j]
            if t <= s2:
                t = s2 + c2
            else:
                if t % f2 == 0:
                    wait = 0
                else:
                    wait = f2 - (t - s2) % f2
                t += c2 + wait
        print(t)


if __name__ == "__main__":
    resolve()

-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 i in range(n): -    t = 0 -    for j in range(i, n - 1): -        if t <= S[j]: -            t = S[j] -        elif (t - S[j]) % F[j] == 0: -            pass -        else: -            t += F[j] - (t - S[j]) % F[j] -        t += C[j] -    print(t) +import sys + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    n = int(eval(input())) +    CSF = [list(map(int, input().split())) for _ in range(n - 1)] +    for i in range(n): +        if i == n - 1: +            print((0)) +            break +        c1, s1, _ = CSF[i] +        t = s1 + c1 +        for j in range(i + 1, n - 1): +            c2, s2, f2 = CSF[j] +            if t <= s2: +                t = s2 + c2 +            else: +                if t % f2 == 0: +                    wait = 0 +                else: +                    wait = f2 - (t - s2) % f2 +                t += c2 + wait +        print(t) + + +if __name__ == "__main__": +    resolve()