N = int(eval(input()))

C, S, F = [], [], []

for _ in range(N-1):

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

    C.append(c)

    S.append(s)

    F.append(f)

S.append(0)



import numpy as np

def theta(x): #ヘヴィサイドの段差関数

    return x if x > 0 else 0



def DptTimeAtNextSt(i, T): #時刻Tに駅iを出発した時、駅i+1を出発する時間

    global C, S, F

    arrT = T + C[i]

    if i == N-2: return arrT 

    return S[i+1] + np.ceil(theta(arrT-S[i+1])/F[i+1]) * F[i+1]



def solve(i, S): #駅iに対する解を再帰的に解く関数

    if i == N-1:

        return int(S)

    else:

        return solve(i+1, DptTimeAtNextSt(i,S))



for i in range(N):

    print((solve(i,S[i])))


def main():

    with open(0) as f:

        N = int(f.readline())

        train = [tuple(map(int, line.split())) for line in f.readlines()]

    

    ans = []

    for start in range(N-1):

        arrive = 0

        for station in range(start, N-1):

            c, s, f = train[station]

            #出発時間:区間[arrive,)の下限     

            departure = lambda arrive:(arrive+f-1)//f*f if arrive >= s else s

            arrive = departure(arrive) + c

        ans.append(arrive)

    ans.append(0)

    for x in ans: print(x)



main()

N = int(eval(input()))
C, S, F = [], [], []
for _ in range(N - 1):
    c, s, f = list(map(int, input().split()))
    C.append(c)
    S.append(s)
    F.append(f)
S.append(0)
import numpy as np


def theta(x):  # ヘヴィサイドの段差関数
    return x if x > 0 else 0


def DptTimeAtNextSt(i, T):  # 時刻Tに駅iを出発した時、駅i+1を出発する時間
    global C, S, F
    arrT = T + C[i]
    if i == N - 2:
        return arrT
    return S[i + 1] + np.ceil(theta(arrT - S[i + 1]) / F[i + 1]) * F[i + 1]


def solve(i, S):  # 駅iに対する解を再帰的に解く関数
    if i == N - 1:
        return int(S)
    else:
        return solve(i + 1, DptTimeAtNextSt(i, S))


for i in range(N):
    print((solve(i, S[i])))

def main():
    with open(0) as f:
        N = int(f.readline())
        train = [tuple(map(int, line.split())) for line in f.readlines()]
    ans = []
    for start in range(N - 1):
        arrive = 0
        for station in range(start, N - 1):
            c, s, f = train[station]
            # 出発時間:区間[arrive,)の下限
            departure = lambda arrive: (arrive + f - 1) // f * f if arrive >= s else s
            arrive = departure(arrive) + c
        ans.append(arrive)
    ans.append(0)
    for x in ans:
        print(x)


main()

-N = int(eval(input())) -C, S, F = [], [], [] -for _ in range(N - 1): -    c, s, f = list(map(int, input().split())) -    C.append(c) -    S.append(s) -    F.append(f) -S.append(0) -import numpy as np +def main(): +    with open(0) as f: +        N = int(f.readline()) +        train = [tuple(map(int, line.split())) for line in f.readlines()] +    ans = [] +    for start in range(N - 1): +        arrive = 0 +        for station in range(start, N - 1): +            c, s, f = train[station] +            # 出発時間:区間[arrive,)の下限 +            departure = lambda arrive: (arrive + f - 1) // f * f if arrive >= s else s +            arrive = departure(arrive) + c +        ans.append(arrive) +    ans.append(0) +    for x in ans: +        print(x) -def theta(x):  # ヘヴィサイドの段差関数 -    return x if x > 0 else 0 - - -def DptTimeAtNextSt(i, T):  # 時刻Tに駅iを出発した時、駅i+1を出発する時間 -    global C, S, F -    arrT = T + C[i] -    if i == N - 2: -        return arrT -    return S[i + 1] + np.ceil(theta(arrT - S[i + 1]) / F[i + 1]) * F[i + 1] - - -def solve(i, S):  # 駅iに対する解を再帰的に解く関数 -    if i == N - 1: -        return int(S) -    else: -        return solve(i + 1, DptTimeAtNextSt(i, S)) - - -for i in range(N): -    print((solve(i, S[i]))) +main()