# N:駅の数

# Ci:i駅から i+1 駅への移動にかかる時間(cost)

# Si:i駅の最初の発車時間(start)

# Fi:i駅の発車スパン(frequency)

# Si % Fi = 0



N = int(eval(input()))

C = [0 for i in range(N)]

S = [0 for i in range(N)]

F = [0 for i in range(N)]

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





for i in range(N-1):

    C[i+1], S[i+1], F[i+1] = (int(i) for i in input().split())



for s in range(1, N+1):

    # print("start=", s)

    if s == N:

        t = 0

        pass

    else:

        t = 0

        for i in range(s, N):

            # print("i =", i)

            # print("S[", i, "] =", S[i])

            if t < S[i]:

                t = S[i]

                t += C[i]

            else:

                for j in range(F[i]):

                    if (t + j) % F[i] == 0:

                        t = t + j

                        # print("notta zikan =", t)

                        t += C[i]

                        # print("tuita zikan =", t)

                        break

    print(t)

# N:駅の数

# Ci:i駅から i+1 駅への移動にかかる時間(cost)

# Si:i駅の最初の発車時間(start)

# Fi:i駅の発車スパン(frequency)

# Si % Fi = 0



N = int(eval(input()))

C = [0 for i in range(N)]

S = [0 for i in range(N)]

F = [0 for i in range(N)]

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





for i in range(N-1):

    C[i+1], S[i+1], F[i+1] = (int(i) for i in input().split())



for s in range(1, N+1):

    # print("start=", s)

    if s == N:

        t = 0

        pass

    else:

        t = 0

        for i in range(s, N):

            if t < S[i]:

                t = S[i]



            elif t % F[i] == 0:

                pass



            else:

                t = t + F[i] - (t % F[i])



            t += C[i]

    print(t)

# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0
N = int(eval(input()))
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0
for i in range(N - 1):
    C[i + 1], S[i + 1], F[i + 1] = (int(i) for i in input().split())
for s in range(1, N + 1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            # print("i =", i)
            # print("S[", i, "] =", S[i])
            if t < S[i]:
                t = S[i]
                t += C[i]
            else:
                for j in range(F[i]):
                    if (t + j) % F[i] == 0:
                        t = t + j
                        # print("notta zikan =", t)
                        t += C[i]
                        # print("tuita zikan =", t)
                        break
    print(t)

# N:駅の数
# Ci:i駅から i+1 駅への移動にかかる時間(cost)
# Si:i駅の最初の発車時間(start)
# Fi:i駅の発車スパン(frequency)
# Si % Fi = 0
N = int(eval(input()))
C = [0 for i in range(N)]
S = [0 for i in range(N)]
F = [0 for i in range(N)]
C[0], S[0], F[0] = 0, 0, 0
for i in range(N - 1):
    C[i + 1], S[i + 1], F[i + 1] = (int(i) for i in input().split())
for s in range(1, N + 1):
    # print("start=", s)
    if s == N:
        t = 0
        pass
    else:
        t = 0
        for i in range(s, N):
            if t < S[i]:
                t = S[i]
            elif t % F[i] == 0:
                pass
            else:
                t = t + F[i] - (t % F[i])
            t += C[i]
    print(t)

-            # print("i =", i) -            # print("S[", i, "] =", S[i]) -                t += C[i] +            elif t % F[i] == 0: +                pass -                for j in range(F[i]): -                    if (t + j) % F[i] == 0: -                        t = t + j -                        # print("notta zikan =", t) -                        t += C[i] -                        # print("tuita zikan =", t) -                        break +                t = t + F[i] - (t % F[i]) +            t += C[i]