import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



n = int(readline())

cfs = [list(map(int, readline().split())) for i in range(n - 1)]

for i in range(n - 1):

    cnt = 0

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

        if cnt < cfs[j][1]:

            cnt = cfs[j][1]

        elif cnt % cfs[j][2] == 0:

            pass

        else:

            cnt += cfs[j][2] - (cnt % cfs[j][2])

        cnt += cfs[j][0]

    print(cnt)

print((0))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



n = int(readline())

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

for i, (c, s, _) in enumerate(csf):

    s += c

    for cc, ss, ff in csf[i + 1:]:

        if s < ss:

            s = ss

        elif s % ff != 0:

            s += ff - (s % ff)

        s += cc

    print(s)

print((0))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n = int(readline())
cfs = [list(map(int, readline().split())) for i in range(n - 1)]
for i in range(n - 1):
    cnt = 0
    for j in range(i, n - 1):
        if cnt < cfs[j][1]:
            cnt = cfs[j][1]
        elif cnt % cfs[j][2] == 0:
            pass
        else:
            cnt += cfs[j][2] - (cnt % cfs[j][2])
        cnt += cfs[j][0]
    print(cnt)
print((0))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
n = int(readline())
csf = [list(map(int, readline().split())) for _ in range(n - 1)]
for i, (c, s, _) in enumerate(csf):
    s += c
    for cc, ss, ff in csf[i + 1 :]:
        if s < ss:
            s = ss
        elif s % ff != 0:
            s += ff - (s % ff)
        s += cc
    print(s)
print((0))

-cfs = [list(map(int, readline().split())) for i in range(n - 1)] -for i in range(n - 1): -    cnt = 0 -    for j in range(i, n - 1): -        if cnt < cfs[j][1]: -            cnt = cfs[j][1] -        elif cnt % cfs[j][2] == 0: -            pass -        else: -            cnt += cfs[j][2] - (cnt % cfs[j][2]) -        cnt += cfs[j][0] -    print(cnt) +csf = [list(map(int, readline().split())) for _ in range(n - 1)] +for i, (c, s, _) in enumerate(csf): +    s += c +    for cc, ss, ff in csf[i + 1 :]: +        if s < ss: +            s = ss +        elif s % ff != 0: +            s += ff - (s % ff) +        s += cc +    print(s)