# -*- coding: utf-8 -*-

def inpl(): return list(map(int, input().split()))



N = int(eval(input()))

stations = []

for _ in range(N-1):

    stations.append(inpl())



P = []



for i in range(N-1):

    C, S, F = stations[i]

    P = [C + max(S, F*(p//F + int(p%F!=0))) for p in P]

    P.append(S+C)  



for p in P:

    print(p)

print((0))
# -*- coding: utf-8 -*-

def inpl(): return list(map(int, input().split()))

N = int(eval(input()))



stations = [inpl() for _ in range(N-1)]



for i in range(N):

    now = 0

    for C, S, F in stations[i:]:

        if now <= S:

            now = S

        now = S + -(-(now - S)//F)*F + C

        

    print(now)

# -*- coding: utf-8 -*-
def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
stations = []
for _ in range(N - 1):
    stations.append(inpl())
P = []
for i in range(N - 1):
    C, S, F = stations[i]
    P = [C + max(S, F * (p // F + int(p % F != 0))) for p in P]
    P.append(S + C)
for p in P:
    print(p)
print((0))

# -*- coding: utf-8 -*-
def inpl():
    return list(map(int, input().split()))


N = int(eval(input()))
stations = [inpl() for _ in range(N - 1)]
for i in range(N):
    now = 0
    for C, S, F in stations[i:]:
        if now <= S:
            now = S
        now = S + -(-(now - S) // F) * F + C
    print(now)

-stations = [] -for _ in range(N - 1): -    stations.append(inpl()) -P = [] -for i in range(N - 1): -    C, S, F = stations[i] -    P = [C + max(S, F * (p // F + int(p % F != 0))) for p in P] -    P.append(S + C) -for p in P: -    print(p) -print((0)) +stations = [inpl() for _ in range(N - 1)] +for i in range(N): +    now = 0 +    for C, S, F in stations[i:]: +        if now <= S: +            now = S +        now = S + -(-(now - S) // F) * F + C +    print(now)