import sys

import math



N = int(eval(input()))

C = []

S = []

F = []



for i in range(N - 1):

    c, s, f = [int(x) for x in input().split()]

    C.append(c)

    S.append(s)

    F.append(f)





def f(idx, t):

    depT = -1

    if t <= S[idx]:

        depT = S[idx]

    else:

        depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])

    return depT + C[idx]





for i in range(N - 1):

    t = 0

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

        t = f(j, t)

    print(t)



print((0))

#!/usr/bin/python3



import sys

# input = sys.stdin.readline

sys.setrecursionlimit(100000)

MOD = 10 ** 9 + 7



#N = int(input())

#A = [int(x) for x in input().split()]

#V = [[0] * 100 for _ in range(100)]



N = int(eval(input()))

CSF = []

for _ in range(N-1):

    C, S, F = [int(x) for x in input().split()]

    CSF.append((C, S, F))



def f(i):

    ans_r = [0]

    cur = 0

    for c, s, f in CSF[i:]:

        cur = max(cur, s)

        if cur % f != 0:

            cur = cur + (f - (cur % f))

        # print("出発：{}".format(cur))

        cur += c

        # print("到着：{}".format(cur))

        ans_r.append(cur)



    return ans_r[-1]



for i in range(N):

    print((f(i)))
import sys
import math

N = int(eval(input()))
C = []
S = []
F = []
for i in range(N - 1):
    c, s, f = [int(x) for x in input().split()]
    C.append(c)
    S.append(s)
    F.append(f)


def f(idx, t):
    depT = -1
    if t <= S[idx]:
        depT = S[idx]
    else:
        depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx])
    return depT + C[idx]


for i in range(N - 1):
    t = 0
    for j in range(i, N - 1):
        t = f(j, t)
    print(t)
print((0))

#!/usr/bin/python3
import sys

# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10**9 + 7
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
N = int(eval(input()))
CSF = []
for _ in range(N - 1):
    C, S, F = [int(x) for x in input().split()]
    CSF.append((C, S, F))


def f(i):
    ans_r = [0]
    cur = 0
    for c, s, f in CSF[i:]:
        cur = max(cur, s)
        if cur % f != 0:
            cur = cur + (f - (cur % f))
        # print("出発：{}".format(cur))
        cur += c
        # print("到着：{}".format(cur))
        ans_r.append(cur)
    return ans_r[-1]


for i in range(N):
    print((f(i)))

+#!/usr/bin/python3 -import math +# input = sys.stdin.readline +sys.setrecursionlimit(100000) +MOD = 10**9 + 7 +# N = int(input()) +# A = [int(x) for x in input().split()] +# V = [[0] * 100 for _ in range(100)] -C = [] -S = [] -F = [] -for i in range(N - 1): -    c, s, f = [int(x) for x in input().split()] -    C.append(c) -    S.append(s) -    F.append(f) +CSF = [] +for _ in range(N - 1): +    C, S, F = [int(x) for x in input().split()] +    CSF.append((C, S, F)) -def f(idx, t): -    depT = -1 -    if t <= S[idx]: -        depT = S[idx] -    else: -        depT = S[idx] + F[idx] * math.ceil((t - S[idx]) / F[idx]) -    return depT + C[idx] +def f(i): +    ans_r = [0] +    cur = 0 +    for c, s, f in CSF[i:]: +        cur = max(cur, s) +        if cur % f != 0: +            cur = cur + (f - (cur % f)) +        # print("出発：{}".format(cur)) +        cur += c +        # print("到着：{}".format(cur)) +        ans_r.append(cur) +    return ans_r[-1] -for i in range(N - 1): -    t = 0 -    for j in range(i, N - 1): -        t = f(j, t) -    print(t) -print((0)) +for i in range(N): +    print((f(i)))